@oliasoft-open-source/node-json-migrator 2.3.3 → 2.3.4-beta-1
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/dist/pending/pending.js +19 -5
- package/package.json +1 -1
package/dist/pending/pending.js
CHANGED
|
@@ -11,10 +11,22 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
11
11
|
const getPendingMigrations = ({
|
|
12
12
|
plannedMigrations,
|
|
13
13
|
executedMigrations,
|
|
14
|
-
printPendingFileNames = false
|
|
14
|
+
printPendingFileNames = false,
|
|
15
|
+
force
|
|
15
16
|
}) => {
|
|
16
|
-
const
|
|
17
|
-
|
|
17
|
+
const pendingMigrations = plannedMigrations.filter(m => {
|
|
18
|
+
const executed = executedMigrations.find(e => e?.fileName === m.fileName);
|
|
19
|
+
const skippedFileHashes = m?.skippedFileHashes;
|
|
20
|
+
const isSkippedAndPreviouslyExecuted = skippedFileHashes?.includes(executed?.fileHash);
|
|
21
|
+
/*
|
|
22
|
+
- always execute migrations that have never been executed
|
|
23
|
+
- re-execute migrations only when all are true:
|
|
24
|
+
- fileHash has changed
|
|
25
|
+
- force flag is active
|
|
26
|
+
- the migration was not previously executed and skipped (see .skip feature for patching migration bugs)
|
|
27
|
+
*/
|
|
28
|
+
return executed === undefined || executed?.fileHash !== m?.fileHash && force && !isSkippedAndPreviouslyExecuted;
|
|
29
|
+
});
|
|
18
30
|
if (printPendingFileNames) {
|
|
19
31
|
pendingMigrations.forEach(m => {
|
|
20
32
|
console.log(_chalk.default.gray(` ${m.fileName}`));
|
|
@@ -36,7 +48,8 @@ const getPendingMigrators = async ({
|
|
|
36
48
|
entity,
|
|
37
49
|
version,
|
|
38
50
|
plan,
|
|
39
|
-
printPendingFileNames
|
|
51
|
+
printPendingFileNames,
|
|
52
|
+
force
|
|
40
53
|
} = config;
|
|
41
54
|
const {
|
|
42
55
|
plannedMigrations,
|
|
@@ -48,7 +61,8 @@ const getPendingMigrators = async ({
|
|
|
48
61
|
const pendingMigrators = getPendingMigrations({
|
|
49
62
|
plannedMigrations,
|
|
50
63
|
executedMigrations,
|
|
51
|
-
printPendingFileNames
|
|
64
|
+
printPendingFileNames,
|
|
65
|
+
force
|
|
52
66
|
});
|
|
53
67
|
return {
|
|
54
68
|
pendingMigrators,
|
package/package.json
CHANGED