Skip to content

Commit

Permalink
chore(v2): remove now unnecessary code parts
Browse files Browse the repository at this point in the history
Signed-off-by: Tobias Gurtzick <magic@wizardtales.com>
  • Loading branch information
wzrdtales committed Jun 1, 2019
1 parent aa3ff89 commit 9334ee2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 62 deletions.
68 changes: 7 additions & 61 deletions lib/executors/versioned/v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,6 @@ const execUnit = {
};
},

learn: (context, driver, file) => {
const _file = file.get();

const i = Learn.getInterface(
context._driver,
file,
driver,
context.internals
);

return _file.migrate(i, {
options: context.internals.safeOptions,
seedLink: context.seedLink,
dbm: context.internals.safeOptions.dbmigrate
});
},

up: async function (context, driver, file) {
const _file = file.get();
const chain = new Chain(context._driver, file, driver, context.internals);
Expand All @@ -50,6 +33,10 @@ const execUnit = {
chain.addChain(Migrate);

await State.startMigration(context._driver, file, context.internals);
// startMigration - needs secondary instance since we can not afford to
// loose state and the transaction start will include these for roll back
// we will disable them probably at all from DDL when the driver does not
// explicitly signal DDL transaction support (like crdb)
try {
await _file.migrate(chain, {
options: context.internals.safeOptions,
Expand All @@ -64,57 +51,16 @@ const execUnit = {
throw err;
}
return Promise.promisify(context.writeMigrationRecord.bind(context))(file);
return execUnit.learn(context, driver, file);

return context.driver
.startMigration()
.then(() => {
const _file = file.get();

return _file.migrate(context.driver, {
options: context.internals.safeOptions,
seedLink: context.seedLink,
dbm: context.internals.safeOptions.dbmigrate
});
})
.then(() => {
return Promise.promisify(context.writeMigrationRecord.bind(context))(
file
);
})
.then(context.driver.endMigration.bind(context.driver));
// end migration, same as start migration
},

down: async function (context, driver, file) {
// start migration, see up comments
await State.startMigration(context._driver, file, context.internals);
await TranslateState(context._driver, file, driver, context.internals);
await State.endMigration(context._driver, file, context.internals);
return Promise.promisify(context.deleteMigrationRecord.bind(context))(file);

await _file.migrate(chain, {
options: context.internals.safeOptions,
seedLink: context.seedLink,
dbm: context.internals.safeOptions.dbmigrate
});
return Promise.promisify(context.deleteMigrationRecord.bind(context))(file);

return driver
.startMigration()
.then(() => {
const _file = file.get();

return _file.down(context.driver, {
options: context.internals.safeOptions,
seedLink: context.seedLink,
dbm: context.internals.safeOptions.dbmigrate
});
})
.then(() => {
return Promise.promisify(context.deleteMigrationRecord.bind(context))(
file
);
})
.then(context.driver.endMigration.bind(context.driver));
// end migration, see up comments
}
};

Expand Down
1 change: 0 additions & 1 deletion lib/methods/v2/statetravel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const Promise = require('bluebird');
const Shadow = require('../../driver/shadow');
const State = require('../../state');
const DEFAULT = {
Expand Down

0 comments on commit 9334ee2

Please sign in to comment.