rake-db 2.15.0 → 2.15.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/index.mjs CHANGED
@@ -2253,7 +2253,9 @@ const getMigratedVersionsMap = async (ctx, adapter, config) => {
2253
2253
  const table = quoteWithSchema({
2254
2254
  name: config.migrationsTable
2255
2255
  });
2256
- const result = await adapter.arrays(`SELECT * FROM ${table}`);
2256
+ const result = await adapter.arrays(
2257
+ `SELECT * FROM ${table}`
2258
+ );
2257
2259
  if (!result.fields[1]) {
2258
2260
  const { migrations } = await getMigrations(ctx, config, true);
2259
2261
  const map = {};
@@ -2261,21 +2263,20 @@ const getMigratedVersionsMap = async (ctx, adapter, config) => {
2261
2263
  const name = path.basename(item.path);
2262
2264
  map[item.version] = name.slice(getDigitsPrefix(name).length + 1);
2263
2265
  }
2264
- const data = result.rows.map(
2265
- ([version]) => {
2266
- const name = map[version];
2267
- if (!name) {
2268
- throw new Error(
2269
- `Migration for version ${version} is stored in db but is not found among available migrations`
2270
- );
2271
- }
2272
- return { version, name };
2266
+ for (const row of result.rows) {
2267
+ const [version] = row;
2268
+ const name = map[version];
2269
+ if (!name) {
2270
+ throw new Error(
2271
+ `Migration for version ${version} is stored in db but is not found among available migrations`
2272
+ );
2273
2273
  }
2274
- );
2274
+ row[1] = name;
2275
+ }
2275
2276
  await adapter.arrays(`ALTER TABLE ${table} ADD COLUMN name TEXT`);
2276
2277
  await Promise.all(
2277
- data.map(
2278
- ({ version, name }) => adapter.arrays({
2278
+ result.rows.map(
2279
+ ([version, name]) => adapter.arrays({
2279
2280
  text: `UPDATE ${table} SET name = $2 WHERE version = $1`,
2280
2281
  values: [version, name]
2281
2282
  })