This commit is contained in:
2020-04-23 17:51:19 +02:00
parent fee3f55300
commit 8bc26b384e
3 changed files with 17 additions and 6 deletions

View File

@ -2,6 +2,6 @@ import { Snippet } from '../../Snippet';
export default class Database implements Snippet {
public start (): Promise<void> {
// noop
return new Promise ((res) => res ());
}
}

View File

@ -36,7 +36,18 @@ export class RenameColumn implements Serializable, PatchAction {
public apply (db: Database): void {
const table = db.get_table (this.table);
const column = table?.get_column(this.column);
column?.name = this.new_name;
if (typeof table === 'undefined' || table === null) {
throw new Error (
`table ${this.table} not found`
);
}
const column = table.get_column (this.column);
if (typeof column === 'undefined' || column === null) {
throw new Error (
`column ${this.column} not found in table ${this.table}`
);
}
column.name = this.new_name;
}
}