rake-db 2.36.19 → 2.37.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/bun.js.map +1 -1
- package/dist/bun.mjs.map +1 -1
- package/dist/index.d.ts +94 -39
- package/dist/index.js +119 -44
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +119 -45
- package/dist/index.mjs.map +1 -1
- package/dist/node-postgres.js.map +1 -1
- package/dist/node-postgres.mjs.map +1 -1
- package/dist/postgres-js.js.map +1 -1
- package/dist/postgres-js.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
19
19
|
value: mod,
|
|
20
20
|
enumerable: true
|
|
21
21
|
}) : target, mod));
|
|
@@ -205,7 +205,7 @@ const addColumnComment = (comments, name, item) => {
|
|
|
205
205
|
};
|
|
206
206
|
const getForeignKeyTable = (schema, fnOrTable) => {
|
|
207
207
|
if (typeof fnOrTable === "string") return getSchemaAndTableFromName(schema, fnOrTable);
|
|
208
|
-
const item =
|
|
208
|
+
const item = (0, pqb_internal.getForeignKeyTableInstance)(fnOrTable());
|
|
209
209
|
return [item.schema, item.table];
|
|
210
210
|
};
|
|
211
211
|
const getConstraintName = (table, constraint, snakeCase) => {
|
|
@@ -394,7 +394,8 @@ const primaryKeyToSql = (primaryKey) => {
|
|
|
394
394
|
};
|
|
395
395
|
const interpolateSqlValues = ({ text, values }) => {
|
|
396
396
|
return values?.length ? text.replace(/\$(\d+)/g, (_, n) => {
|
|
397
|
-
|
|
397
|
+
const i = +n - 1;
|
|
398
|
+
return (0, pqb_internal.escapeForMigration)(values[i]);
|
|
398
399
|
}) : text;
|
|
399
400
|
};
|
|
400
401
|
const nameColumnChecks = (table, column, checks) => checks.map((check, i) => ({
|
|
@@ -432,6 +433,33 @@ const migrationsSchemaTableSql = (adapter, config) => {
|
|
|
432
433
|
};
|
|
433
434
|
var RakeDbError = class extends Error {};
|
|
434
435
|
var NoPrimaryKey = class extends RakeDbError {};
|
|
436
|
+
const getTableFactoryConfig = ({ baseTable, defineTable }) => {
|
|
437
|
+
if (baseTable && defineTable) throw new Error("Configure either baseTable or defineTable, not both");
|
|
438
|
+
if (defineTable) {
|
|
439
|
+
if (!defineTable.types) throw new Error("defineTable is missing types");
|
|
440
|
+
if (!defineTable.exportAs) throw new Error("defineTable is missing exportAs");
|
|
441
|
+
if (typeof defineTable.getFilePath !== "function") throw new Error("defineTable is missing getFilePath");
|
|
442
|
+
return {
|
|
443
|
+
columnTypes: defineTable.types,
|
|
444
|
+
exportAs: defineTable.exportAs,
|
|
445
|
+
getFilePath: defineTable.getFilePath,
|
|
446
|
+
nowSQL: defineTable.nowSQL,
|
|
447
|
+
snakeCase: defineTable.snakeCase,
|
|
448
|
+
language: defineTable.language
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
if (baseTable) {
|
|
452
|
+
const { types, snakeCase, language } = baseTable.prototype || {};
|
|
453
|
+
return {
|
|
454
|
+
columnTypes: types,
|
|
455
|
+
exportAs: baseTable.exportAs,
|
|
456
|
+
getFilePath: baseTable.getFilePath,
|
|
457
|
+
nowSQL: baseTable.nowSQL,
|
|
458
|
+
snakeCase,
|
|
459
|
+
language
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
};
|
|
435
463
|
const createTable$1 = async (migration, tableMethods, up, tableName, first, second, third) => {
|
|
436
464
|
let options;
|
|
437
465
|
let fn;
|
|
@@ -451,7 +479,8 @@ const createTable$1 = async (migration, tableMethods, up, tableName, first, seco
|
|
|
451
479
|
let shape;
|
|
452
480
|
let tableData;
|
|
453
481
|
if (fn) {
|
|
454
|
-
|
|
482
|
+
const tableFactory = getTableFactoryConfig(migration.options);
|
|
483
|
+
shape = (0, pqb_internal.getColumnTypes)(types, fn, tableFactory?.nowSQL, language);
|
|
455
484
|
tableData = (0, pqb_internal.parseTableData)(dataFn);
|
|
456
485
|
tableData.constraints?.forEach((x, i) => {
|
|
457
486
|
if (x.name || !x.check) return;
|
|
@@ -488,7 +517,7 @@ const makeAst$5 = (schema, up, tableName, shape, tableData, options, noPrimaryKe
|
|
|
488
517
|
...tableData,
|
|
489
518
|
primaryKey: shapePKeys.length <= 1 ? primaryKey : primaryKey ? {
|
|
490
519
|
...primaryKey,
|
|
491
|
-
columns: [
|
|
520
|
+
columns: [.../* @__PURE__ */ new Set([...shapePKeys, ...primaryKey.columns])]
|
|
492
521
|
} : { columns: shapePKeys },
|
|
493
522
|
...options,
|
|
494
523
|
noPrimaryKey: options.noPrimaryKey ? "ignore" : noPrimaryKey || "error"
|
|
@@ -874,6 +903,25 @@ const makeTableChangeMethods = (tableMethods) => ({
|
|
|
874
903
|
to: { comment }
|
|
875
904
|
};
|
|
876
905
|
},
|
|
906
|
+
/**
|
|
907
|
+
* Rename a column:
|
|
908
|
+
*
|
|
909
|
+
* ```ts
|
|
910
|
+
* import { change } from '../dbScript';
|
|
911
|
+
*
|
|
912
|
+
* change(async (db) => {
|
|
913
|
+
* await db.changeTable('table', (t) => ({
|
|
914
|
+
* oldColumnName: t.rename('newColumnName'),
|
|
915
|
+
* }));
|
|
916
|
+
* });
|
|
917
|
+
* ```
|
|
918
|
+
*
|
|
919
|
+
* Note that the renaming `ALTER TABLE` is executed before the rest of alterations,
|
|
920
|
+
* so if you're also adding a new constraint on this column inside the same `changeTable`,
|
|
921
|
+
* refer to it with a new name.
|
|
922
|
+
*
|
|
923
|
+
* @param name
|
|
924
|
+
*/
|
|
877
925
|
rename(name) {
|
|
878
926
|
return {
|
|
879
927
|
type: "rename",
|
|
@@ -892,7 +940,8 @@ const changeTable = async (migration, tableChangeMethods, up, tableName, options
|
|
|
892
940
|
standaloneCheckChanges.length = 0;
|
|
893
941
|
const changeData = fn?.(tableChanger) || {};
|
|
894
942
|
const schema = migration.adapter.getSchema();
|
|
895
|
-
const
|
|
943
|
+
const ast = makeAst$4(schema, up, tableName, changeData, changeTableData, options);
|
|
944
|
+
const queries = astToQueries(schema, ast, snakeCase, language);
|
|
896
945
|
for (const query of queries) {
|
|
897
946
|
const result = await migration.adapter.arrays(interpolateSqlValues(query));
|
|
898
947
|
query.then?.(result);
|
|
@@ -1171,7 +1220,9 @@ const renameColumnSql = (from, to) => {
|
|
|
1171
1220
|
return `RENAME COLUMN "${from}" TO "${to}"`;
|
|
1172
1221
|
};
|
|
1173
1222
|
const createView = async (migration, up, name, options, sql) => {
|
|
1174
|
-
const
|
|
1223
|
+
const schema = migration.adapter.getSchema();
|
|
1224
|
+
const ast = makeAst$3(schema, up, name, options, sql);
|
|
1225
|
+
const query = astToQuery$2(ast);
|
|
1175
1226
|
await migration.adapter.arrays(interpolateSqlValues(query));
|
|
1176
1227
|
};
|
|
1177
1228
|
const makeAst$3 = (schema, up, fullName, options, sql) => {
|
|
@@ -1218,12 +1269,15 @@ const astToQuery$2 = (ast) => {
|
|
|
1218
1269
|
};
|
|
1219
1270
|
};
|
|
1220
1271
|
const createMaterializedView = async (migration, up, name, options, sql) => {
|
|
1221
|
-
const
|
|
1272
|
+
const schema = migration.adapter.getSchema();
|
|
1273
|
+
const ast = makeAst$2(schema, up, name, options, sql);
|
|
1274
|
+
const query = astToQuery$1(ast);
|
|
1222
1275
|
await migration.adapter.arrays(interpolateSqlValues(query));
|
|
1223
1276
|
};
|
|
1224
1277
|
const refreshMaterializedView = async (migration, name, options = {}) => {
|
|
1225
1278
|
if (options.concurrently && options.withData === false) throw new Error("Cannot refresh a materialized view concurrently with WITH NO DATA");
|
|
1226
|
-
const
|
|
1279
|
+
const schema = migration.adapter.getSchema();
|
|
1280
|
+
const [s, viewName] = getSchemaAndTableFromName(schema, name);
|
|
1227
1281
|
const sql = ["REFRESH MATERIALIZED VIEW"];
|
|
1228
1282
|
if (options.concurrently) sql.push("CONCURRENTLY");
|
|
1229
1283
|
sql.push(`${s ? `"${s}".` : ""}"${viewName}"`);
|
|
@@ -1281,7 +1335,8 @@ const serializers = {
|
|
|
1281
1335
|
validUntil: (value) => `VALID UNTIL '${value === void 0 ? "infinity" : value}'`
|
|
1282
1336
|
};
|
|
1283
1337
|
const createOrDropRole = async (migration, up, name, params) => {
|
|
1284
|
-
const
|
|
1338
|
+
const ast = makeAst$1(up, name, params);
|
|
1339
|
+
const sql = astToQuery(ast);
|
|
1285
1340
|
await migration.adapter.arrays(sql);
|
|
1286
1341
|
};
|
|
1287
1342
|
const makeAst$1 = (up, name, params) => {
|
|
@@ -1333,7 +1388,8 @@ const changeRole = async (migration, up, name, from, to) => {
|
|
|
1333
1388
|
for (const key in from.config) if (!(key in config)) config[key] = void 0;
|
|
1334
1389
|
}
|
|
1335
1390
|
}
|
|
1336
|
-
const
|
|
1391
|
+
const ast = makeChangeAst(name, from, to);
|
|
1392
|
+
const sql = changeAstToQuery(ast);
|
|
1337
1393
|
if (sql) await migration.adapter.arrays(sql);
|
|
1338
1394
|
};
|
|
1339
1395
|
const makeChangeAst = (name, from, to) => {
|
|
@@ -1372,7 +1428,8 @@ const renameRole = async (migration, up, from, to) => {
|
|
|
1372
1428
|
from = to;
|
|
1373
1429
|
to = f;
|
|
1374
1430
|
}
|
|
1375
|
-
const
|
|
1431
|
+
const ast = makeRenameAst(from, to);
|
|
1432
|
+
const sql = renameAstToQuery(ast);
|
|
1376
1433
|
if (sql) await migration.adapter.arrays(sql);
|
|
1377
1434
|
};
|
|
1378
1435
|
const makeRenameAst = (from, to) => ({
|
|
@@ -1424,7 +1481,8 @@ const filterAndTransformConfig = (config, schema) => {
|
|
|
1424
1481
|
return Object.keys(result).length ? result : void 0;
|
|
1425
1482
|
};
|
|
1426
1483
|
const changeDefaultPrivileges = async (migration, up, arg) => {
|
|
1427
|
-
const
|
|
1484
|
+
const ast = makeAst(up, arg);
|
|
1485
|
+
const sql = astToSql(ast);
|
|
1428
1486
|
if (sql.length) await migration.adapter.arrays(sql.join(";\n"));
|
|
1429
1487
|
};
|
|
1430
1488
|
const makeAst = (up, arg) => {
|
|
@@ -1577,7 +1635,9 @@ const recreatePolicy = async (migration, tableName, policyName, from, to) => {
|
|
|
1577
1635
|
const fromTable = from.table ?? tableName;
|
|
1578
1636
|
const fromName = from.name ?? policyName;
|
|
1579
1637
|
await migration.adapter.arrays(dropPolicySql(migration, fromTable, fromName));
|
|
1580
|
-
const
|
|
1638
|
+
const toTable = to.table ?? tableName;
|
|
1639
|
+
const toName = to.name ?? policyName;
|
|
1640
|
+
const { text, values } = createPolicySql(migration, toTable, toName, to);
|
|
1581
1641
|
await migration.adapter.arrays(text, values);
|
|
1582
1642
|
};
|
|
1583
1643
|
const changePolicy = async (migration, up, tableName, policyName, params) => {
|
|
@@ -1605,18 +1665,19 @@ const schemaOrDatabaseTargetKeyToSql = {
|
|
|
1605
1665
|
schemas: "SCHEMA",
|
|
1606
1666
|
databases: "DATABASE"
|
|
1607
1667
|
};
|
|
1608
|
-
const specialRoleSpecs = new Set([
|
|
1668
|
+
const specialRoleSpecs = /* @__PURE__ */ new Set([
|
|
1609
1669
|
"PUBLIC",
|
|
1610
1670
|
"CURRENT_ROLE",
|
|
1611
1671
|
"CURRENT_USER",
|
|
1612
1672
|
"SESSION_USER"
|
|
1613
1673
|
]);
|
|
1614
1674
|
const changeGrant = async (migration, up, params) => {
|
|
1615
|
-
const
|
|
1675
|
+
const ast = {
|
|
1616
1676
|
...params,
|
|
1617
1677
|
to: typeof params.to === "string" ? [params.to] : params.to,
|
|
1618
1678
|
action: up ? "grant" : "revoke"
|
|
1619
|
-
}
|
|
1679
|
+
};
|
|
1680
|
+
const sql = privilegeToSql(migration, ast);
|
|
1620
1681
|
if (sql.length) await migration.adapter.arrays(sql.join(";\n"));
|
|
1621
1682
|
};
|
|
1622
1683
|
const privilegeToSql = (migration, ast) => {
|
|
@@ -1741,7 +1802,10 @@ const createMigrationInterface = (tx, up, config) => {
|
|
|
1741
1802
|
var Migration = class {
|
|
1742
1803
|
getTableMethods() {
|
|
1743
1804
|
let { tableMethods } = this;
|
|
1744
|
-
if (!tableMethods)
|
|
1805
|
+
if (!tableMethods) {
|
|
1806
|
+
const schemaConfig = (0, pqb_internal.defaultSchemaConfig)();
|
|
1807
|
+
tableMethods = makeTableMethods(schemaConfig);
|
|
1808
|
+
}
|
|
1745
1809
|
return tableMethods;
|
|
1746
1810
|
}
|
|
1747
1811
|
getTableChangeMethods() {
|
|
@@ -2822,7 +2886,8 @@ const addOrDropEnumValues = async (migration, up, enumName, values, options) =>
|
|
|
2822
2886
|
return;
|
|
2823
2887
|
}
|
|
2824
2888
|
const { rows: valuesRows } = await migration.adapter.query(`SELECT unnest(enum_range(NULL::${quotedName}))::text value`);
|
|
2825
|
-
|
|
2889
|
+
const existingValues = valuesRows.map((r) => r.value);
|
|
2890
|
+
await recreateEnum(migration, ast, existingValues.filter((v) => !ast.values.includes(v)), (quotedName, table, column) => `Cannot drop ${quotedName} enum values [${ast.values.map(pqb_internal.singleQuote).join(", ")}]: table ${table} has a row with such value in the column "${column}"`);
|
|
2826
2891
|
};
|
|
2827
2892
|
const changeEnumValues = async (migration, enumName, fromValues, toValues) => {
|
|
2828
2893
|
const [schema, name] = getSchemaAndTableFromName(migration.adapter.getSchema(), enumName);
|
|
@@ -2879,11 +2944,13 @@ GROUP BY n.nspname, c.relname`);
|
|
|
2879
2944
|
const writeMigrationFile = async (config, version, name, migrationCode) => {
|
|
2880
2945
|
await (0, node_fs_promises.mkdir)(config.migrationsPath, { recursive: true });
|
|
2881
2946
|
const filePath = node_path.default.resolve(config.migrationsPath, `${version}_${name.replaceAll(" ", "-")}.ts`);
|
|
2882
|
-
|
|
2947
|
+
const importPath = (0, pqb_internal.getImportPath)(filePath, node_path.default.join(config.basePath, config.dbScript));
|
|
2948
|
+
await (0, node_fs_promises.writeFile)(filePath, `import { change } from '${importPath}';\n${migrationCode}`);
|
|
2883
2949
|
config.logger?.log(`Created ${(0, pqb_internal.pathToLog)(filePath)}`);
|
|
2884
2950
|
};
|
|
2885
2951
|
const newMigration = async (config, name) => {
|
|
2886
|
-
|
|
2952
|
+
const version = await makeFileVersion({}, config);
|
|
2953
|
+
await writeMigrationFile(config, version, name, makeContent(name));
|
|
2887
2954
|
};
|
|
2888
2955
|
const makeFileVersion = async (ctx, config) => {
|
|
2889
2956
|
if (config.migrationId === "timestamp") return generateTimeStamp();
|
|
@@ -3198,7 +3265,8 @@ const saveMigratedVersion = async (db, version, name, config) => {
|
|
|
3198
3265
|
await db.silentArrays(`INSERT INTO ${migrationsSchemaTableSql(db, config)}(version, name) VALUES ($1, $2)`, [version, name]);
|
|
3199
3266
|
};
|
|
3200
3267
|
const createMigrationsSchemaAndTable = async (db, config) => {
|
|
3201
|
-
const
|
|
3268
|
+
const adapter = getMaybeTransactionAdapter(db);
|
|
3269
|
+
const { schema, table } = getMigrationsSchemaAndTable(adapter, config);
|
|
3202
3270
|
if (schema) {
|
|
3203
3271
|
if (await createSchema(db, schema) === "done") config.logger?.log(`Created schema "${schema}"`);
|
|
3204
3272
|
}
|
|
@@ -3290,10 +3358,10 @@ const processMigrateConfig = (config, db) => {
|
|
|
3290
3358
|
migrationsPath,
|
|
3291
3359
|
...handleConfigLogger(config, db)
|
|
3292
3360
|
};
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
if (snakeCase) result.snakeCase = true;
|
|
3296
|
-
if (language) result.language = language;
|
|
3361
|
+
const tableFactory = getTableFactoryConfig(config);
|
|
3362
|
+
if (tableFactory) {
|
|
3363
|
+
if (tableFactory.snakeCase) result.snakeCase = true;
|
|
3364
|
+
if (tableFactory.language) result.language = tableFactory.language;
|
|
3297
3365
|
}
|
|
3298
3366
|
return result;
|
|
3299
3367
|
};
|
|
@@ -3311,12 +3379,14 @@ function makeMigrateFn(up, defaultCount, fn) {
|
|
|
3311
3379
|
let migrations;
|
|
3312
3380
|
try {
|
|
3313
3381
|
await transactionIfSingle(adapter, config, async (trx) => {
|
|
3314
|
-
|
|
3382
|
+
const versions = await getMigratedVersionsMap(ctx, trx, config, set.renameTo);
|
|
3383
|
+
migrations = await fn(trx, config, set, versions, count, force);
|
|
3315
3384
|
});
|
|
3316
3385
|
} catch (err) {
|
|
3317
3386
|
if (err instanceof NoMigrationsTableError) await transactionIfSingle(adapter, config, async (trx) => {
|
|
3318
3387
|
await createMigrationsSchemaAndTable(trx, config);
|
|
3319
|
-
|
|
3388
|
+
const versions = await getMigratedVersionsMap(ctx, trx, config, set.renameTo);
|
|
3389
|
+
migrations = await fn(trx, config, set, versions, count, force);
|
|
3320
3390
|
});
|
|
3321
3391
|
else throw err;
|
|
3322
3392
|
}
|
|
@@ -3352,9 +3422,11 @@ async function runMigration(db, ...args) {
|
|
|
3352
3422
|
...rawConfig,
|
|
3353
3423
|
...handleConfigLogger(rawConfig)
|
|
3354
3424
|
};
|
|
3355
|
-
|
|
3425
|
+
const adapter = getMaybeTransactionAdapter(db);
|
|
3426
|
+
await transaction(adapter, config, async (trx) => {
|
|
3356
3427
|
clearChanges();
|
|
3357
|
-
|
|
3428
|
+
const changes = await getChanges({ load: migration });
|
|
3429
|
+
await applyMigration(trx, true, changes, config);
|
|
3358
3430
|
});
|
|
3359
3431
|
}
|
|
3360
3432
|
/**
|
|
@@ -3437,7 +3509,8 @@ const migrateOrRollback = async (trx, config, set, versions, count, up, redo, fo
|
|
|
3437
3509
|
loggedAboutStarting = true;
|
|
3438
3510
|
config.logger?.log(`${redo ? "Reapplying migrations for" : up ? "Migrating" : "Rolling back"} database ${getAdapterDatabase$1(trx)}\n`);
|
|
3439
3511
|
}
|
|
3440
|
-
|
|
3512
|
+
const adapter = await migrationRunner(trx, up, await getChanges(file, config), config);
|
|
3513
|
+
await changeMigratedVersion(adapter, up, file, config);
|
|
3441
3514
|
(migrations ??= []).push(file);
|
|
3442
3515
|
if (up) {
|
|
3443
3516
|
const name = node_path.default.basename(file.path);
|
|
@@ -3818,11 +3891,12 @@ const astToGenerateItem = (config, ast, currentSchema) => {
|
|
|
3818
3891
|
const keys = ast.action === "create" ? add : drop;
|
|
3819
3892
|
keys.push(table);
|
|
3820
3893
|
deps.push(schema);
|
|
3821
|
-
|
|
3894
|
+
const columns = Object.entries(ast.shape).map(([name, column]) => [
|
|
3822
3895
|
keys,
|
|
3823
3896
|
name,
|
|
3824
3897
|
{ column }
|
|
3825
|
-
])
|
|
3898
|
+
]);
|
|
3899
|
+
analyzeTableColumns(config, currentSchema, schema, table, deps, resolveType, columns);
|
|
3826
3900
|
if (ast.type === "table") analyzeTableData(config, currentSchema, schema, table, keys, deps, ast);
|
|
3827
3901
|
else deps.push(...ast.deps.map(({ schemaName, name }) => `${schemaName}.${name}`));
|
|
3828
3902
|
} else {
|
|
@@ -5682,9 +5756,7 @@ const viewToAst = (ctx, data, domains, view) => {
|
|
|
5682
5756
|
case "securityBarrier":
|
|
5683
5757
|
options.securityBarrier = value === "true";
|
|
5684
5758
|
break;
|
|
5685
|
-
case "securityInvoker":
|
|
5686
|
-
options.securityInvoker = value === "true";
|
|
5687
|
-
break;
|
|
5759
|
+
case "securityInvoker": options.securityInvoker = value === "true";
|
|
5688
5760
|
}
|
|
5689
5761
|
}
|
|
5690
5762
|
return {
|
|
@@ -5832,14 +5904,16 @@ const checkIfIsOuterRecursiveFkey = (data, table, references) => {
|
|
|
5832
5904
|
const pullDbStructure = async (adapter, config) => {
|
|
5833
5905
|
const currentSchema = adapter.getSearchPath?.() ?? adapter.searchPath ?? "public";
|
|
5834
5906
|
const ctx = makeStructureToAstCtx(config, currentSchema);
|
|
5835
|
-
const
|
|
5907
|
+
const ast = await structureToAst(ctx, adapter, config);
|
|
5908
|
+
const result = astToMigration(currentSchema, config, ast);
|
|
5836
5909
|
if (!result) return;
|
|
5837
5910
|
const version = await makeFileVersion({}, config);
|
|
5838
5911
|
await writeMigrationFile(config, version, "pull", result);
|
|
5839
|
-
|
|
5912
|
+
const silentQueries = Object.assign(adapter, {
|
|
5840
5913
|
silentQuery: adapter.query,
|
|
5841
5914
|
silentArrays: adapter.arrays
|
|
5842
|
-
})
|
|
5915
|
+
});
|
|
5916
|
+
await saveMigratedVersion(silentQueries, version, "pull", config);
|
|
5843
5917
|
const unsupportedEntries = Object.entries(ctx.unsupportedTypes);
|
|
5844
5918
|
if (unsupportedEntries.length) {
|
|
5845
5919
|
let count = 0;
|
|
@@ -6089,7 +6163,8 @@ const rakeDbCommands = {
|
|
|
6089
6163
|
},
|
|
6090
6164
|
status: {
|
|
6091
6165
|
run(adapters, config, args) {
|
|
6092
|
-
|
|
6166
|
+
const showUrl = args.includes("p") || args.includes("path");
|
|
6167
|
+
return listMigrationsStatuses(adapters, config, { showUrl });
|
|
6093
6168
|
},
|
|
6094
6169
|
help: "list migrations statuses",
|
|
6095
6170
|
helpArguments: {
|
|
@@ -6148,6 +6223,7 @@ const ensureBasePathAndDbScript = (config, intermediateCallers = 0) => {
|
|
|
6148
6223
|
const makeRakeDbConfig = (config, args) => {
|
|
6149
6224
|
const ic = intermediateCallers;
|
|
6150
6225
|
intermediateCallers = 0;
|
|
6226
|
+
const tableFactory = getTableFactoryConfig(config);
|
|
6151
6227
|
const result = {
|
|
6152
6228
|
...rakeDbConfigDefaults,
|
|
6153
6229
|
...config,
|
|
@@ -6157,10 +6233,8 @@ const makeRakeDbConfig = (config, args) => {
|
|
|
6157
6233
|
Object.assign(result, processMigrateConfig(result));
|
|
6158
6234
|
if (!result.recurrentPath && result.migrationsPath) result.recurrentPath = node_path.default.join(result.migrationsPath, "recurrent");
|
|
6159
6235
|
if (result.recurrentPath && !node_path.default.isAbsolute(result.recurrentPath)) result.recurrentPath = node_path.default.resolve(result.basePath, result.recurrentPath);
|
|
6160
|
-
if (
|
|
6161
|
-
|
|
6162
|
-
result.columnTypes = types || (0, pqb_internal.makeColumnTypes)((0, pqb_internal.defaultSchemaConfig)());
|
|
6163
|
-
} else {
|
|
6236
|
+
if (tableFactory) result.columnTypes = tableFactory.columnTypes || (0, pqb_internal.makeColumnTypes)((0, pqb_internal.defaultSchemaConfig)());
|
|
6237
|
+
else {
|
|
6164
6238
|
const ct = "columnTypes" in config && config.columnTypes;
|
|
6165
6239
|
result.columnTypes = (typeof ct === "function" ? ct((0, pqb_internal.makeColumnTypes)((0, pqb_internal.defaultSchemaConfig)())) : ct) || (0, pqb_internal.makeColumnTypes)((0, pqb_internal.defaultSchemaConfig)());
|
|
6166
6240
|
}
|
|
@@ -6290,6 +6364,7 @@ exports.getExcludeName = getExcludeName;
|
|
|
6290
6364
|
exports.getIndexName = getIndexName;
|
|
6291
6365
|
exports.getMigrationsSchemaAndTable = getMigrationsSchemaAndTable;
|
|
6292
6366
|
exports.getSchemaAndTableFromName = getSchemaAndTableFromName;
|
|
6367
|
+
exports.getTableFactoryConfig = getTableFactoryConfig;
|
|
6293
6368
|
exports.incrementIntermediateCaller = incrementIntermediateCaller;
|
|
6294
6369
|
exports.instantiateDbColumn = instantiateDbColumn;
|
|
6295
6370
|
exports.introspectDbSchema = introspectDbSchema;
|