|
1 |
| -var log = require('db-migrate-shared').log; |
2 |
| -var Promise = require('bluebird'); |
| 1 | +const Promise = require('bluebird'); |
| 2 | +const { maybePromise } = require('../../temputils.js'); |
3 | 3 |
|
4 | 4 | const execUnit = {
|
5 |
| - up: function (context, driver, execUnit) { |
| 5 | + up: function (context, driver, file) { |
6 | 6 | return context.driver
|
7 | 7 | .startMigration()
|
8 | 8 | .then(() => {
|
9 |
| - var setup = execUnit.setup; |
| 9 | + const _file = file.get(); |
10 | 10 |
|
11 |
| - if (typeof setup === 'function') { |
12 |
| - setup(context.internals.execUnitOptions, context.seedLink); |
| 11 | + if (typeof _file.setup === 'function') { |
| 12 | + _file.setup(context.internals.fileOptions, context.seedLink); |
13 | 13 | }
|
14 | 14 |
|
15 |
| - return execUnit.up(); |
| 15 | + return maybePromise(_file.up); |
16 | 16 | })
|
17 | 17 | .then(() => {
|
18 |
| - return Promise.promisify(context.writeexecUnitRecord.bind(context))( |
19 |
| - execUnit |
20 |
| - ); |
| 18 | + return Promise.promisify(context.writeRecord.bind(context))(file); |
21 | 19 | })
|
22 | 20 | .then(context.driver.endMigration.bind(context.driver));
|
23 | 21 | },
|
24 | 22 |
|
25 |
| - down: function (context, driver, execUnit) { |
| 23 | + down: function (context, driver, file) { |
26 | 24 | return driver
|
27 | 25 | .startMigration()
|
28 | 26 | .then(() => {
|
29 |
| - var setup = execUnit.setup; |
| 27 | + const _file = file.get(); |
30 | 28 |
|
31 |
| - if (typeof setup === 'function') { |
32 |
| - setup(context.internals.execUnitOptions, context.seedLink); |
| 29 | + if (typeof _file.setup === 'function') { |
| 30 | + _file.setup(context.internals.fileOptions, context.seedLink); |
33 | 31 | }
|
34 | 32 |
|
35 |
| - return execUnit.down(); |
| 33 | + return maybePromise(_file.down); |
36 | 34 | })
|
37 | 35 | .then(() => {
|
38 |
| - return Promise.promisify(context.deleteexecUnitRecord.bind(context))( |
39 |
| - execUnit |
40 |
| - ); |
| 36 | + return Promise.promisify(context.deleteRecord.bind(context))(file); |
41 | 37 | })
|
42 | 38 | .then(context.driver.endMigration.bind(context.driver));
|
43 | 39 | }
|
|
0 commit comments