rake-db 2.4.19 → 2.4.23
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.d.ts +2 -1
- package/dist/index.js +14 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -247,6 +247,7 @@ declare const migrateOrRollback: (options: MaybeArray<AdapterOptions>, config: R
|
|
|
247
247
|
declare const changeCache: Record<string, ChangeCallback[] | undefined>;
|
|
248
248
|
declare const migrate: (options: MaybeArray<AdapterOptions>, config: RakeDbConfig, args?: string[]) => Promise<void>;
|
|
249
249
|
declare const rollback: (options: MaybeArray<AdapterOptions>, config: RakeDbConfig, args?: string[]) => Promise<void>;
|
|
250
|
+
declare const redo: (options: MaybeArray<AdapterOptions>, config: RakeDbConfig, args?: string[]) => Promise<void>;
|
|
250
251
|
|
|
251
252
|
declare const rakeDb: (options: MaybeArray<AdapterOptions>, partialConfig?: Partial<RakeDbConfig>, args?: string[]) => Promise<void>;
|
|
252
253
|
|
|
@@ -254,4 +255,4 @@ declare const saveMigratedVersion: (db: Adapter, version: string, config: RakeDb
|
|
|
254
255
|
declare const removeMigratedVersion: (db: Adapter, version: string, config: RakeDbConfig) => Promise<void>;
|
|
255
256
|
declare const getMigratedVersionsMap: (db: Adapter, config: RakeDbConfig) => Promise<Record<string, boolean>>;
|
|
256
257
|
|
|
257
|
-
export { AppCodeUpdater, ChangeTableCallback, ChangeTableOptions, ColumnComment, ColumnsShapeCallback, DropMode, Migration, MigrationBase, MigrationColumnTypes, RakeDbAst, RakeDbConfig, TableOptions, change, changeCache, createDb, createMigrationInterface, dropDb, generate, getMigratedVersionsMap, makeFileTimeStamp, migrate, migrateOrRollback, rakeDb, removeMigratedVersion, resetDb, rollback, saveMigratedVersion, writeMigrationFile };
|
|
258
|
+
export { AppCodeUpdater, ChangeTableCallback, ChangeTableOptions, ColumnComment, ColumnsShapeCallback, DropMode, Migration, MigrationBase, MigrationColumnTypes, RakeDbAst, RakeDbConfig, TableOptions, change, changeCache, createDb, createMigrationInterface, dropDb, generate, getMigratedVersionsMap, makeFileTimeStamp, migrate, migrateOrRollback, rakeDb, redo, removeMigratedVersion, resetDb, rollback, saveMigratedVersion, writeMigrationFile };
|
package/dist/index.js
CHANGED
|
@@ -1565,6 +1565,10 @@ const processMigration = async (db, up, file, config, options, appCodeUpdaterCac
|
|
|
1565
1565
|
};
|
|
1566
1566
|
const migrate = (options, config, args = []) => migrateOrRollback(options, config, args, true);
|
|
1567
1567
|
const rollback = (options, config, args = []) => migrateOrRollback(options, config, args, false);
|
|
1568
|
+
const redo = async (options, config, args = []) => {
|
|
1569
|
+
await migrateOrRollback(options, config, args, false);
|
|
1570
|
+
await migrateOrRollback(options, config, args, true);
|
|
1571
|
+
};
|
|
1568
1572
|
|
|
1569
1573
|
const execute = async (options, sql) => {
|
|
1570
1574
|
const db = new pqb.Adapter(options);
|
|
@@ -2133,11 +2137,6 @@ var __objRest = (source, exclude) => {
|
|
|
2133
2137
|
}
|
|
2134
2138
|
return target;
|
|
2135
2139
|
};
|
|
2136
|
-
class RakeDbEnumColumn extends pqb.EnumColumn {
|
|
2137
|
-
toCode(t) {
|
|
2138
|
-
return pqb.columnCode(this, t, `enum('${this.enumName}')`);
|
|
2139
|
-
}
|
|
2140
|
-
}
|
|
2141
2140
|
const matchMap = {
|
|
2142
2141
|
s: void 0,
|
|
2143
2142
|
f: "FULL",
|
|
@@ -2330,7 +2329,7 @@ const getColumn = (ctx, data, domains, _a) => {
|
|
|
2330
2329
|
(item) => item.name === type && item.schemaName === typeSchema
|
|
2331
2330
|
);
|
|
2332
2331
|
if (enumType) {
|
|
2333
|
-
column = new
|
|
2332
|
+
column = new pqb.EnumColumn({}, type, enumType.values);
|
|
2334
2333
|
} else {
|
|
2335
2334
|
column = new pqb.CustomTypeColumn({}, type);
|
|
2336
2335
|
((_b2 = (_a2 = ctx.unsupportedTypes)[type]) != null ? _b2 : _a2[type] = []).push(
|
|
@@ -2598,7 +2597,7 @@ const createTable = (config, ast) => {
|
|
|
2598
2597
|
if (hasTimestamps && (key === "createdAt" || key === "updatedAt"))
|
|
2599
2598
|
continue;
|
|
2600
2599
|
const line = [`${orchidCore.quoteObjectKey(key)}: `];
|
|
2601
|
-
for (const part of ast.shape[key].toCode("t")) {
|
|
2600
|
+
for (const part of ast.shape[key].toCode("t", true)) {
|
|
2602
2601
|
orchidCore.addCode(line, part);
|
|
2603
2602
|
}
|
|
2604
2603
|
orchidCore.addCode(line, ",");
|
|
@@ -2699,7 +2698,9 @@ const rakeDb = async (options, partialConfig = {}, args = process.argv.slice(2))
|
|
|
2699
2698
|
await migrate(options, config, args.slice(1));
|
|
2700
2699
|
} else if (command === "rollback") {
|
|
2701
2700
|
await rollback(options, config, args.slice(1));
|
|
2702
|
-
} else if (command === "
|
|
2701
|
+
} else if (command === "redo") {
|
|
2702
|
+
await redo(options, config, args.slice(1));
|
|
2703
|
+
} else if (command === "new") {
|
|
2703
2704
|
await generate(config, args.slice(1));
|
|
2704
2705
|
} else if (command === "pull") {
|
|
2705
2706
|
await pullDbStructure(orchidCore.toArray(options)[0], config);
|
|
@@ -2722,9 +2723,10 @@ Commands:
|
|
|
2722
2723
|
create create databases
|
|
2723
2724
|
drop drop databases
|
|
2724
2725
|
reset drop, create and migrate databases
|
|
2725
|
-
|
|
2726
|
+
new create new migration file, see below
|
|
2726
2727
|
migrate migrate pending migrations
|
|
2727
2728
|
rollback rollback the last migrated
|
|
2729
|
+
redo rollback and migrate
|
|
2728
2730
|
no or unknown command prints this message
|
|
2729
2731
|
|
|
2730
2732
|
Migrate arguments:
|
|
@@ -2740,7 +2742,7 @@ Migrate and rollback common arguments:
|
|
|
2740
2742
|
--code run code updater, overrides \`useCodeUpdater\` option
|
|
2741
2743
|
--code false do not run code updater
|
|
2742
2744
|
|
|
2743
|
-
|
|
2745
|
+
New migration file arguments:
|
|
2744
2746
|
- (required) first argument is migration name
|
|
2745
2747
|
* create* template for create table
|
|
2746
2748
|
* change* template for change table
|
|
@@ -2749,7 +2751,7 @@ Generate arguments:
|
|
|
2749
2751
|
* drop* template for drop table
|
|
2750
2752
|
|
|
2751
2753
|
- other arguments considered as columns with types and optional methods:
|
|
2752
|
-
rake-db
|
|
2754
|
+
rake-db new createTable id:serial.primaryKey name:text.nullable
|
|
2753
2755
|
`;
|
|
2754
2756
|
|
|
2755
2757
|
exports.MigrationBase = MigrationBase;
|
|
@@ -2764,6 +2766,7 @@ exports.makeFileTimeStamp = makeFileTimeStamp;
|
|
|
2764
2766
|
exports.migrate = migrate;
|
|
2765
2767
|
exports.migrateOrRollback = migrateOrRollback;
|
|
2766
2768
|
exports.rakeDb = rakeDb;
|
|
2769
|
+
exports.redo = redo;
|
|
2767
2770
|
exports.removeMigratedVersion = removeMigratedVersion;
|
|
2768
2771
|
exports.resetDb = resetDb;
|
|
2769
2772
|
exports.rollback = rollback;
|