egon-orm-workspace / egon-orm/migration / MigrationDefinition
Interface: MigrationDefinition ​
Defined in: core/src/migration/define.ts:30
What a migration is written as: up makes the change, down undoes it. Both are required. When there is nothing to undo, down is an empty function with a // noop comment.
Example ​
ts
const definition: MigrationDefinition = {
up(m) {
m.execute(fragment`update users set role = 'member' where role is null`);
},
down() {
// noop: the backfill leaves nothing to undo
},
};Properties ​
transaction? ​
ts
readonly transaction?: boolean;Defined in: core/src/migration/define.ts:38
Runs the migration in a transaction (the default) where the database has transactional DDL. false runs it without one, which concurrently index operations need; a failure can then leave it half applied.
Methods ​
down() ​
ts
down(m): void | Promise<void>;Defined in: core/src/migration/define.ts:32
Parameters ​
m ​
Returns ​
void | Promise<void>
up() ​
ts
up(m): void | Promise<void>;Defined in: core/src/migration/define.ts:31
Parameters ​
m ​
Returns ​
void | Promise<void>

