Skip to content

Commit 9334ee2

Browse files
committed
chore(v2): remove now unnecessary code parts
Signed-off-by: Tobias Gurtzick <magic@wizardtales.com>
1 parent aa3ff89 commit 9334ee2

File tree

2 files changed

+7
-62
lines changed

2 files changed

+7
-62
lines changed

lib/executors/versioned/v2.js

+7-61
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,6 @@ const execUnit = {
2525
};
2626
},
2727

28-
learn: (context, driver, file) => {
29-
const _file = file.get();
30-
31-
const i = Learn.getInterface(
32-
context._driver,
33-
file,
34-
driver,
35-
context.internals
36-
);
37-
38-
return _file.migrate(i, {
39-
options: context.internals.safeOptions,
40-
seedLink: context.seedLink,
41-
dbm: context.internals.safeOptions.dbmigrate
42-
});
43-
},
44-
4528
up: async function (context, driver, file) {
4629
const _file = file.get();
4730
const chain = new Chain(context._driver, file, driver, context.internals);
@@ -50,6 +33,10 @@ const execUnit = {
5033
chain.addChain(Migrate);
5134

5235
await State.startMigration(context._driver, file, context.internals);
36+
// startMigration - needs secondary instance since we can not afford to
37+
// loose state and the transaction start will include these for roll back
38+
// we will disable them probably at all from DDL when the driver does not
39+
// explicitly signal DDL transaction support (like crdb)
5340
try {
5441
await _file.migrate(chain, {
5542
options: context.internals.safeOptions,
@@ -64,57 +51,16 @@ const execUnit = {
6451
throw err;
6552
}
6653
return Promise.promisify(context.writeMigrationRecord.bind(context))(file);
67-
return execUnit.learn(context, driver, file);
68-
69-
return context.driver
70-
.startMigration()
71-
.then(() => {
72-
const _file = file.get();
73-
74-
return _file.migrate(context.driver, {
75-
options: context.internals.safeOptions,
76-
seedLink: context.seedLink,
77-
dbm: context.internals.safeOptions.dbmigrate
78-
});
79-
})
80-
.then(() => {
81-
return Promise.promisify(context.writeMigrationRecord.bind(context))(
82-
file
83-
);
84-
})
85-
.then(context.driver.endMigration.bind(context.driver));
54+
// end migration, same as start migration
8655
},
8756

8857
down: async function (context, driver, file) {
58+
// start migration, see up comments
8959
await State.startMigration(context._driver, file, context.internals);
9060
await TranslateState(context._driver, file, driver, context.internals);
9161
await State.endMigration(context._driver, file, context.internals);
9262
return Promise.promisify(context.deleteMigrationRecord.bind(context))(file);
93-
94-
await _file.migrate(chain, {
95-
options: context.internals.safeOptions,
96-
seedLink: context.seedLink,
97-
dbm: context.internals.safeOptions.dbmigrate
98-
});
99-
return Promise.promisify(context.deleteMigrationRecord.bind(context))(file);
100-
101-
return driver
102-
.startMigration()
103-
.then(() => {
104-
const _file = file.get();
105-
106-
return _file.down(context.driver, {
107-
options: context.internals.safeOptions,
108-
seedLink: context.seedLink,
109-
dbm: context.internals.safeOptions.dbmigrate
110-
});
111-
})
112-
.then(() => {
113-
return Promise.promisify(context.deleteMigrationRecord.bind(context))(
114-
file
115-
);
116-
})
117-
.then(context.driver.endMigration.bind(context.driver));
63+
// end migration, see up comments
11864
}
11965
};
12066

lib/methods/v2/statetravel.js

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const Promise = require('bluebird');
21
const Shadow = require('../../driver/shadow');
32
const State = require('../../state');
43
const DEFAULT = {

0 commit comments

Comments
 (0)