Skip to content

Commit 584a172

Browse files
committed
fix: do not reload state on rollback
Signed-off-by: Tobias Gurtzick <[email protected]>
1 parent 18649fc commit 584a172

File tree

1 file changed

+7
-3
lines changed
  • lib/executors/versioned

1 file changed

+7
-3
lines changed

lib/executors/versioned/v2.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const execUnit = {
5858
'An error occured. No alternative failure strategy defined. Rolling back!',
5959
err
6060
);
61-
await execUnit.down(context, driver, file);
61+
await execUnit.down(context, driver, file, { abort: true });
6262
throw err;
6363
}
6464
await Promise.promisify(context.writeMigrationRecord.bind(context))(file);
@@ -104,9 +104,13 @@ const execUnit = {
104104
// end migration, same as start migration
105105
},
106106

107-
down: async function (context, driver, file) {
107+
down: async function (context, driver, file, { abort } = {}) {
108+
// if we get the abort signal this means we are in a rollback routine
109+
// which means in turn we want to avoid reloading the state
110+
if (abort === true) {
111+
await State.startMigration(context._pdriver, file, context.internals);
112+
}
108113
// start migration, see up comments
109-
await State.startMigration(context._pdriver, file, context.internals);
110114
await TranslateState(context._driver, file, driver, context.internals, context._pdriver);
111115
await State.endMigration(context._pdriver, file, context.internals);
112116
return Promise.promisify(context.deleteMigrationRecord.bind(context))(file);

0 commit comments

Comments
 (0)