db-migrate 1.1.0 → 1.2.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.
|
@@ -2,11 +2,33 @@
|
|
|
2
2
|
|
|
3
3
|
const Promise = require('bluebird');
|
|
4
4
|
const maybePromised = require('../../temputils.js').maybePromised;
|
|
5
|
+
const log = require('db-migrate-shared').log;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* A migration runs inside a transaction of the driver, unless it opts out
|
|
9
|
+
* with _meta.transactions = false, e.g. for statements which can not run
|
|
10
|
+
* inside one, like CREATE INDEX CONCURRENTLY of PostgreSQL.
|
|
11
|
+
*/
|
|
12
|
+
const transactional = file => {
|
|
13
|
+
const _meta = file.get()._meta || {};
|
|
14
|
+
|
|
15
|
+
if (_meta.transactions === false) {
|
|
16
|
+
log.verbose(`[migration] ${file.name} runs without a transaction`);
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return true;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const start = (driver, file) =>
|
|
24
|
+
transactional(file) ? driver.startMigration() : Promise.resolve();
|
|
25
|
+
|
|
26
|
+
const end = (driver, file) =>
|
|
27
|
+
transactional(file) ? driver.endMigration() : Promise.resolve();
|
|
5
28
|
|
|
6
29
|
const execUnit = {
|
|
7
30
|
up: function (context, driver, file) {
|
|
8
|
-
return context.driver
|
|
9
|
-
.startMigration()
|
|
31
|
+
return start(context.driver, file)
|
|
10
32
|
.then(() => {
|
|
11
33
|
const _file = file.get();
|
|
12
34
|
|
|
@@ -21,12 +43,11 @@ const execUnit = {
|
|
|
21
43
|
file
|
|
22
44
|
);
|
|
23
45
|
})
|
|
24
|
-
.then(
|
|
46
|
+
.then(() => end(context.driver, file));
|
|
25
47
|
},
|
|
26
48
|
|
|
27
49
|
down: function (context, driver, file) {
|
|
28
|
-
return driver
|
|
29
|
-
.startMigration()
|
|
50
|
+
return start(driver, file)
|
|
30
51
|
.then(() => {
|
|
31
52
|
const _file = file.get();
|
|
32
53
|
|
|
@@ -41,7 +62,7 @@ const execUnit = {
|
|
|
41
62
|
file
|
|
42
63
|
);
|
|
43
64
|
})
|
|
44
|
-
.then(
|
|
65
|
+
.then(() => end(context.driver, file));
|
|
45
66
|
}
|
|
46
67
|
};
|
|
47
68
|
|
package/package.json
CHANGED
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"programmable",
|
|
32
32
|
"api"
|
|
33
33
|
],
|
|
34
|
-
"version": "1.
|
|
34
|
+
"version": "1.2.0",
|
|
35
35
|
"bugs": {
|
|
36
36
|
"url": "https://github.com/db-migrate/node-db-migrate/issues"
|
|
37
37
|
},
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"@hapi/code": "9.x",
|
|
58
58
|
"@hapi/eslint-plugin": "^6.0.0",
|
|
59
59
|
"@hapi/lab": "25.x",
|
|
60
|
-
"db-migrate-base": "^2.
|
|
61
|
-
"db-migrate-mysql": "^
|
|
62
|
-
"db-migrate-sqlite3": "^
|
|
60
|
+
"db-migrate-base": "^2.4.1",
|
|
61
|
+
"db-migrate-mysql": "^3.1.1",
|
|
62
|
+
"db-migrate-sqlite3": "^1.1.1",
|
|
63
63
|
"eslint": "^7.32.0",
|
|
64
64
|
"eslint-config-standard": "^14.1.1",
|
|
65
65
|
"eslint-plugin-import": "^2.26.0",
|
|
@@ -79,5 +79,9 @@
|
|
|
79
79
|
"pretest": "eslint *.js lib/*.js",
|
|
80
80
|
"test": "lab",
|
|
81
81
|
"test:coverage": "lab -r html -o coverage.html"
|
|
82
|
+
},
|
|
83
|
+
"overrides": {
|
|
84
|
+
"tar": "^7.5.21",
|
|
85
|
+
"node-gyp": "^12.0.0"
|
|
82
86
|
}
|
|
83
87
|
}
|