db-migrate 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api.js +9 -0
- package/lib/commands/generated.js +2 -1
- package/lib/commands/work.js +33 -0
- package/lib/dml.js +458 -101
- package/lib/driver/index.js +2 -0
- package/lib/jobs.js +177 -0
- package/lib/walker.js +51 -3
- package/lib/work.js +260 -0
- package/package.json +2 -2
package/api.js
CHANGED
|
@@ -421,6 +421,15 @@ dbmigrate.prototype = {
|
|
|
421
421
|
this.internals.onComplete = callback;
|
|
422
422
|
},
|
|
423
423
|
|
|
424
|
+
/**
|
|
425
|
+
* Runs the jobs of background migrations, see lib/work.js for the
|
|
426
|
+
* options. Returns { done, stop }, done resolves with the jobs done and
|
|
427
|
+
* failed.
|
|
428
|
+
*/
|
|
429
|
+
executeWork: function (options) {
|
|
430
|
+
return load('work')(this.internals, this.config, options);
|
|
431
|
+
},
|
|
432
|
+
|
|
424
433
|
/**
|
|
425
434
|
* Inserts the rows of the static seeds in seeds-dir, all or the one named,
|
|
426
435
|
* removing the rows of their earlier runs first.
|
|
@@ -25,7 +25,8 @@ const files = {
|
|
|
25
25
|
"set-default-argv": require('./set-default-argv.js'),
|
|
26
26
|
"sync": require('./sync.js'),
|
|
27
27
|
"undo-seed": require('./undo-seed.js'),
|
|
28
|
-
"up": require('./up.js')
|
|
28
|
+
"up": require('./up.js'),
|
|
29
|
+
"work": require('./work.js')
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
function register (module) {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const migrationHook = require('./helper/migration-hook.js');
|
|
4
|
+
const executeWork = require('../work');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Runs the jobs of background migrations, returns { done, stop }.
|
|
8
|
+
*/
|
|
9
|
+
module.exports = function (internals, config, options) {
|
|
10
|
+
let worker = null;
|
|
11
|
+
let stopped = false;
|
|
12
|
+
|
|
13
|
+
const done = Promise.resolve(migrationHook(internals)).then(() => {
|
|
14
|
+
if (stopped) {
|
|
15
|
+
return { done: [], failed: [] };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
worker = executeWork(internals, config, options);
|
|
19
|
+
return worker.done;
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
done,
|
|
24
|
+
stop: () => {
|
|
25
|
+
stopped = true;
|
|
26
|
+
if (worker) {
|
|
27
|
+
worker.stop();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return done;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
};
|