rake-db 2.10.66 → 2.10.67

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 CHANGED
@@ -244,9 +244,7 @@ function getMigrationsFromConfig(config, up) {
244
244
  load: migrations[key]
245
245
  });
246
246
  }
247
- if (!up)
248
- result.reverse();
249
- return result;
247
+ return up ? result : result.reverse();
250
248
  }
251
249
  async function getMigrationsFromFiles(config, up) {
252
250
  const { migrationsPath, import: imp } = config;
@@ -2320,8 +2318,13 @@ const processMigration = async (db, up, file, config, options, appCodeUpdaterCac
2320
2318
  changeCache[file.path] = changes;
2321
2319
  }
2322
2320
  const db2 = createMigrationInterface(tx, up, config);
2323
- for (const fn of up ? changes : changes.reverse()) {
2324
- await fn(db2, up);
2321
+ if (changes.length) {
2322
+ const from = up ? 0 : changes.length - 1;
2323
+ const to = up ? changes.length : -1;
2324
+ const step = up ? 1 : -1;
2325
+ for (let i = from; i !== to; i += step) {
2326
+ await changes[i](db2, up);
2327
+ }
2325
2328
  }
2326
2329
  await (up ? saveMigratedVersion : removeMigratedVersion)(
2327
2330
  db2.adapter,
@@ -2346,11 +2349,7 @@ const processMigration = async (db, up, file, config, options, appCodeUpdaterCac
2346
2349
  const migrate = (options, config, args = []) => migrateOrRollback(options, config, args, true);
2347
2350
  const rollback = (options, config, args = []) => migrateOrRollback(options, config, args, false);
2348
2351
  const redo = async (options, config, args = []) => {
2349
- var _a;
2350
2352
  await migrateOrRollback(options, config, args, false);
2351
- for (const file in changeCache) {
2352
- (_a = changeCache[file]) == null ? void 0 : _a.reverse();
2353
- }
2354
2353
  await migrateOrRollback(options, config, args, true);
2355
2354
  };
2356
2355