rake-db 2.15.5 → 2.15.7
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/index.js +5 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -105,6 +105,7 @@ var __spreadValues$a = (a, b) => {
|
|
|
105
105
|
return a;
|
|
106
106
|
};
|
|
107
107
|
var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
|
|
108
|
+
const versionToString = (config, version) => config.migrationId === "serial" ? `${version}`.padStart(4, "0") : `${version}`;
|
|
108
109
|
const columnTypeToSql = (item) => {
|
|
109
110
|
return item.data.isOfCustomType ? `"${item.toSQL()}"` : item.toSQL();
|
|
110
111
|
};
|
|
@@ -2512,7 +2513,7 @@ const migrateOrRollback = async (trx, config, set, versions, count, asts, up, fo
|
|
|
2512
2513
|
var _a, _b, _c;
|
|
2513
2514
|
const { sequence, map: versionsMap } = versions;
|
|
2514
2515
|
if (up) {
|
|
2515
|
-
const rollbackTo = checkMigrationOrder(set, versions, force);
|
|
2516
|
+
const rollbackTo = checkMigrationOrder(config, set, versions, force);
|
|
2516
2517
|
if (rollbackTo) {
|
|
2517
2518
|
let i = sequence.length - 1;
|
|
2518
2519
|
for (; i >= 0; i--) {
|
|
@@ -2561,18 +2562,18 @@ const migrateOrRollback = async (trx, config, set, versions, count, asts, up, fo
|
|
|
2561
2562
|
}
|
|
2562
2563
|
await ((_c = config[up ? "afterMigrate" : "afterRollback"]) == null ? void 0 : _c.call(config, db != null ? db : db = getDb(trx)));
|
|
2563
2564
|
};
|
|
2564
|
-
const checkMigrationOrder = (set, { sequence, map }, force) => {
|
|
2565
|
+
const checkMigrationOrder = (config, set, { sequence, map }, force) => {
|
|
2565
2566
|
const last = sequence[sequence.length - 1];
|
|
2566
2567
|
if (last) {
|
|
2567
2568
|
for (const file of set.migrations) {
|
|
2568
2569
|
const version = +file.version;
|
|
2569
|
-
if (version > last || map[version])
|
|
2570
|
+
if (version > last || map[file.version])
|
|
2570
2571
|
continue;
|
|
2571
2572
|
if (!force) {
|
|
2572
2573
|
throw new Error(
|
|
2573
2574
|
`Cannot migrate ${path.basename(
|
|
2574
2575
|
file.path
|
|
2575
|
-
)} because the higher position ${map[last]} was already migrated.
|
|
2576
|
+
)} because the higher position ${map[versionToString(config, last)]} was already migrated.
|
|
2576
2577
|
Run \`**db command** up force\` to rollback the above migrations and migrate all`
|
|
2577
2578
|
);
|
|
2578
2579
|
}
|