ddl-manager
Version:
store postgres procedures and triggers in files
38 lines (33 loc) • 1.06 kB
text/typescript
import { Migration } from "./Migration";
import { IDatabaseDriver } from "../database/interface";
import { Database as DatabaseStructure } from "../database/schema/Database";
export abstract class AbstractMigrator {
abstract drop(): Promise<void>;
abstract create(): Promise<void>;
protected postgres: IDatabaseDriver;
protected outputErrors: Error[];
protected migration: Migration;
protected database: DatabaseStructure;
constructor(
postgres: IDatabaseDriver,
migration: Migration,
database: DatabaseStructure,
outputErrors: Error[]
) {
this.postgres = postgres;
this.migration = migration;
this.database = database;
this.outputErrors = outputErrors;
}
protected onError(
obj: {getSignature(): string},
err: Error
) {
// redefine callstack
const newErr = new Error(
obj.getSignature() + "\n" +
((err as any).stack || "")
);
this.outputErrors.push(newErr);
}
}