@oliasoft-open-source/node-json-migrator 2.3.7-beta-1 → 2.3.7-beta-2
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/plan/plan.js +5 -5
- package/package.json +1 -1
package/dist/plan/plan.js
CHANGED
|
@@ -131,15 +131,15 @@ const generatePlanEntries = sortedMigrationEntries => sortedMigrationEntries.map
|
|
|
131
131
|
sequence: m.sequence
|
|
132
132
|
}));
|
|
133
133
|
exports.generatePlanEntries = generatePlanEntries;
|
|
134
|
-
const loadMigrationFunctions = async (sortedMigrationEntries,
|
|
134
|
+
const loadMigrationFunctions = async (sortedMigrationEntries, nextVersion, importModule = true) => {
|
|
135
135
|
const cachedPlannedVersion = (0, _cachedPlannedVersion.getCachedPlannedVersion)();
|
|
136
136
|
const cachedMigratorFunctions = (0, _cachedPlannedVersion.getCachedMigratorFunctions)();
|
|
137
|
-
const cacheValid = cachedPlannedVersion ===
|
|
137
|
+
const cacheValid = cachedPlannedVersion === nextVersion && sortedMigrationEntries.length === cachedMigratorFunctions.length;
|
|
138
138
|
const migrationFunctions = cacheValid ? cachedMigratorFunctions : await Promise.all(sortedMigrationEntries.map(async m => {
|
|
139
139
|
const {
|
|
140
140
|
script
|
|
141
141
|
} = m;
|
|
142
|
-
const migrator = script ? (await (0, _moduleFromString.importFromString)(script))?.default : null;
|
|
142
|
+
const migrator = script && importModule ? (await (0, _moduleFromString.importFromString)(script))?.default : null;
|
|
143
143
|
return {
|
|
144
144
|
fileHash: m.fileHash,
|
|
145
145
|
migrator
|
|
@@ -147,6 +147,7 @@ const loadMigrationFunctions = async (sortedMigrationEntries, currentPlanVersion
|
|
|
147
147
|
}));
|
|
148
148
|
if (!cacheValid) {
|
|
149
149
|
(0, _cachedPlannedVersion.setCachedMigratorFunctions)(migrationFunctions);
|
|
150
|
+
(0, _cachedPlannedVersion.setCachedPlannedVersion)(nextVersion);
|
|
150
151
|
}
|
|
151
152
|
return (0, _lodash.merge)(sortedMigrationEntries, migrationFunctions);
|
|
152
153
|
};
|
|
@@ -253,8 +254,7 @@ const getPlannedMigrations = async ({
|
|
|
253
254
|
}];
|
|
254
255
|
await (0, _database.insertVersions)(database, pgpHelpers, entity, versionRecord);
|
|
255
256
|
}
|
|
256
|
-
const plannedMigrationsWithFunctions =
|
|
257
|
-
(0, _cachedPlannedVersion.setCachedPlannedVersion)(nextVersion); //Must set _after_ loading migration functions
|
|
257
|
+
const plannedMigrationsWithFunctions = await loadMigrationFunctions(plannedMigrationsWithFileEntries, nextVersion, importModule);
|
|
258
258
|
return {
|
|
259
259
|
plannedMigrations: plannedMigrationsWithFunctions,
|
|
260
260
|
nextVersion
|
package/package.json
CHANGED