rake-db 2.18.0 → 2.19.0
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 +67 -105
- package/dist/index.js +185 -225
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +187 -227
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
1
|
import * as orchid_core from 'orchid-core';
|
|
2
2
|
import { MaybeArray, RawSQLBase, ColumnDataCheckBase, RecordString, EmptyObject, ColumnSchemaConfig, RecordOptionalString, ColumnTypeBase, ForeignKeyTable, Sql, MaybePromise } from 'orchid-core';
|
|
3
3
|
import * as pqb from 'pqb';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
interface TableQuery {
|
|
7
|
-
text: string;
|
|
8
|
-
values?: unknown[];
|
|
9
|
-
then?(result: QueryArraysResult): void;
|
|
10
|
-
}
|
|
11
|
-
interface CreateTableResult<Table extends string, Shape extends ColumnsShape> {
|
|
12
|
-
table: Db$1<Table, Shape>;
|
|
13
|
-
}
|
|
4
|
+
import { TableData, ColumnsShape, NoPrimaryKeyOption, ColumnType, EnumColumn, raw, Adapter, DbResult, TransactionAdapter, QueryLogObject, TableDataFn, TableDataItem, DbDomainArg, TextColumn, Db as Db$1, QueryArraysResult, AdapterOptions, DefaultColumnTypes, DefaultSchemaConfig, QueryLogOptions, SearchWeight, ColumnsByType, ArrayColumn } from 'pqb';
|
|
14
5
|
|
|
15
6
|
type RakeDbAst = RakeDbAst.Table | RakeDbAst.ChangeTable | RakeDbAst.RenameType | RakeDbAst.Schema | RakeDbAst.RenameSchema | RakeDbAst.Extension | RakeDbAst.Enum | RakeDbAst.EnumValues | RakeDbAst.RenameEnumValues | RakeDbAst.ChangeEnumValues | RakeDbAst.Domain | RakeDbAst.Collation | RakeDbAst.Constraint | RakeDbAst.RenameTableItem | RakeDbAst.View;
|
|
16
7
|
declare namespace RakeDbAst {
|
|
@@ -69,11 +60,8 @@ declare namespace RakeDbAst {
|
|
|
69
60
|
compression?: string;
|
|
70
61
|
primaryKey?: boolean;
|
|
71
62
|
check?: ColumnDataCheckBase;
|
|
72
|
-
foreignKeys?:
|
|
73
|
-
|
|
74
|
-
columns: string[];
|
|
75
|
-
} & ForeignKeyOptions)[];
|
|
76
|
-
indexes?: Omit<SingleColumnIndexOptions, 'column' | 'expression'>[];
|
|
63
|
+
foreignKeys?: TableData.ColumnReferences[];
|
|
64
|
+
indexes?: TableData.ColumnIndex[];
|
|
77
65
|
identity?: TableData.Identity;
|
|
78
66
|
}
|
|
79
67
|
interface RenameType {
|
|
@@ -218,7 +206,7 @@ type Change = RakeDbAst.ChangeTableItem.Change & ChangeOptions;
|
|
|
218
206
|
type ChangeOptions = RakeDbAst.ChangeTableItem.ChangeUsing;
|
|
219
207
|
type TableChangeMethods = typeof tableChangeMethods;
|
|
220
208
|
declare const tableChangeMethods: {
|
|
221
|
-
name(
|
|
209
|
+
name(name: string): any;
|
|
222
210
|
add: typeof add;
|
|
223
211
|
drop: typeof add;
|
|
224
212
|
change(from: ColumnType | Change, to: ColumnType | Change, using?: ChangeOptions): Change;
|
|
@@ -227,6 +215,19 @@ declare const tableChangeMethods: {
|
|
|
227
215
|
nonNullable(): Change;
|
|
228
216
|
comment(comment: string | null): Change;
|
|
229
217
|
rename(name: string): RakeDbAst.ChangeTableItem.Rename;
|
|
218
|
+
primaryKey<Columns extends [string, ...string[]], Name extends string>(columns: Columns, name?: Name | undefined): {
|
|
219
|
+
columns: Columns;
|
|
220
|
+
name: string extends Name ? never : Name;
|
|
221
|
+
};
|
|
222
|
+
unique<Columns_1 extends [string | TableData.Index.ColumnOrExpressionOptions<string>, ...(string | TableData.Index.ColumnOrExpressionOptions<string>)[]], Name_1 extends string>(columns: Columns_1, ...args: [options?: TableData.Index.UniqueOptionsArg | undefined] | [name?: Name_1 | undefined, options?: TableData.Index.UniqueOptionsArg | undefined]): {
|
|
223
|
+
columns: Columns_1 extends (string | TableData.Index.ColumnOptionsForColumn<string>)[] ? { [I in keyof Columns_1]: "column" extends keyof Columns_1[I] ? Columns_1[I][keyof Columns_1[I] & "column"] : Columns_1[I]; } : never;
|
|
224
|
+
name: string extends Name_1 ? never : Name_1;
|
|
225
|
+
};
|
|
226
|
+
index(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], ...args: [options?: TableData.Index.OptionsArg | undefined] | [name?: string | undefined, options?: TableData.Index.OptionsArg | undefined]): pqb.TableDataItem;
|
|
227
|
+
searchIndex(columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], ...args: [options?: TableData.Index.TsVectorArg | undefined] | [name?: string | undefined, options?: TableData.Index.TsVectorArg | undefined]): pqb.TableDataItem;
|
|
228
|
+
foreignKey<ForeignTable extends string | (() => orchid_core.ForeignKeyTable), ForeignColumns extends ForeignTable extends () => orchid_core.ForeignKeyTable ? [orchid_core.ColumnNameOfTable<ReturnType<ForeignTable>>, ...orchid_core.ColumnNameOfTable<ReturnType<ForeignTable>>[]] : [string, ...string[]]>(columns: [string, ...string[]], fnOrTable: ForeignTable, foreignColumns: ForeignColumns, options?: TableData.References.Options | undefined): pqb.TableDataItem;
|
|
229
|
+
check(check: RawSQLBase<orchid_core.QueryColumn<unknown, orchid_core.CoreBaseOperators>, unknown>, name?: string | undefined): pqb.TableDataItem;
|
|
230
|
+
sql: pqb.SqlFn;
|
|
230
231
|
enum(name: string): EnumColumn<pqb.DefaultSchemaConfig, undefined, string, [string, ...string[]]>;
|
|
231
232
|
};
|
|
232
233
|
type TableChanger<CT> = MigrationColumnTypes<CT> & TableChangeMethods;
|
|
@@ -265,27 +266,7 @@ type SilentQueries = {
|
|
|
265
266
|
silentQuery: Adapter['query'];
|
|
266
267
|
silentArrays: Adapter['arrays'];
|
|
267
268
|
};
|
|
268
|
-
|
|
269
|
-
index(columns: MaybeArray<string | IndexColumnOptions>, options?: IndexOptions): EmptyObject;
|
|
270
|
-
foreignKey(columns: [string, ...string[]], foreignTable: string, foreignColumns: [string, ...string[]], options?: ForeignKeyOptions): EmptyObject;
|
|
271
|
-
primaryKey(columns: string[], options?: {
|
|
272
|
-
name?: string;
|
|
273
|
-
}): EmptyObject;
|
|
274
|
-
check(check: RawSQLBase): EmptyObject;
|
|
275
|
-
constraint(arg: ConstraintArg): EmptyObject;
|
|
276
|
-
}
|
|
277
|
-
interface ConstraintArg {
|
|
278
|
-
name?: string;
|
|
279
|
-
references?: [
|
|
280
|
-
columns: [string, ...string[]],
|
|
281
|
-
table: string,
|
|
282
|
-
foreignColumn: [string, ...string[]],
|
|
283
|
-
options: Omit<ForeignKeyOptions, 'name' | 'dropMode'>
|
|
284
|
-
];
|
|
285
|
-
check?: RawSQLBase;
|
|
286
|
-
dropMode?: DropMode;
|
|
287
|
-
}
|
|
288
|
-
type DbMigration<CT extends RakeDbColumnTypes> = DbResult<CT> & Migration<CT> & {
|
|
269
|
+
type DbMigration<CT> = DbResult<CT> & Migration<CT> & {
|
|
289
270
|
adapter: SilentQueries;
|
|
290
271
|
};
|
|
291
272
|
/**
|
|
@@ -296,11 +277,11 @@ type DbMigration<CT extends RakeDbColumnTypes> = DbResult<CT> & Migration<CT> &
|
|
|
296
277
|
* @param up - migrate or rollback
|
|
297
278
|
* @param config - config of `rakeDb`
|
|
298
279
|
*/
|
|
299
|
-
declare const createMigrationInterface: <SchemaConfig extends ColumnSchemaConfig<orchid_core.ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any, orchid_core.CoreBaseOperators, unknown, unknown, any, unknown, any, orchid_core.ColumnDataBase>>, CT
|
|
280
|
+
declare const createMigrationInterface: <SchemaConfig extends ColumnSchemaConfig<orchid_core.ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any, orchid_core.CoreBaseOperators, unknown, unknown, any, unknown, any, orchid_core.ColumnDataBase>>, CT>(tx: TransactionAdapter, up: boolean, config: RakeDbConfig<SchemaConfig, CT>) => DbMigration<CT>;
|
|
300
281
|
interface MigrationAdapter extends TransactionAdapter {
|
|
301
282
|
schema: string;
|
|
302
283
|
}
|
|
303
|
-
declare class Migration<CT
|
|
284
|
+
declare class Migration<CT> {
|
|
304
285
|
adapter: MigrationAdapter;
|
|
305
286
|
log?: QueryLogObject;
|
|
306
287
|
up: boolean;
|
|
@@ -380,31 +361,35 @@ declare class Migration<CT extends RakeDbColumnTypes> {
|
|
|
380
361
|
*
|
|
381
362
|
* @param tableName - name of the table to create
|
|
382
363
|
* @param fn - create table callback
|
|
364
|
+
* @param dataFn - callback for creating composite indexes, primary keys, foreign keys
|
|
383
365
|
*/
|
|
384
|
-
createTable<Table extends string, Shape extends ColumnsShape>(tableName: Table, fn?: ColumnsShapeCallback<CT, Shape
|
|
366
|
+
createTable<Table extends string, Shape extends ColumnsShape>(tableName: Table, fn?: ColumnsShapeCallback<CT, Shape>, dataFn?: TableDataFn<Shape, MaybeArray<TableDataItem>>): Promise<CreateTableResult<Table, Shape>>;
|
|
385
367
|
/**
|
|
386
368
|
* See {@link createTable}
|
|
387
369
|
*
|
|
388
370
|
* @param tableName - name of the table to create
|
|
389
371
|
* @param options - {@link TableOptions}
|
|
390
372
|
* @param fn - create table callback
|
|
373
|
+
* @param dataFn - callback for creating composite indexes, primary keys, foreign keys
|
|
391
374
|
*/
|
|
392
|
-
createTable<Table extends string, Shape extends ColumnsShape>(tableName: Table, options: TableOptions, fn?: ColumnsShapeCallback<CT, Shape
|
|
375
|
+
createTable<Table extends string, Shape extends ColumnsShape>(tableName: Table, options: TableOptions, fn?: ColumnsShapeCallback<CT, Shape>, dataFn?: TableDataFn<Shape, MaybeArray<TableDataItem>>): Promise<CreateTableResult<Table, Shape>>;
|
|
393
376
|
/**
|
|
394
377
|
* Drop the table, create it on rollback. See {@link createTable}.
|
|
395
378
|
*
|
|
396
379
|
* @param tableName - name of the table to drop
|
|
397
380
|
* @param fn - create table callback
|
|
381
|
+
* @param dataFn - callback for creating composite indexes, primary keys, foreign keys
|
|
398
382
|
*/
|
|
399
|
-
dropTable<Table extends string, Shape extends ColumnsShape>(tableName: Table, fn?: ColumnsShapeCallback<CT, Shape
|
|
383
|
+
dropTable<Table extends string, Shape extends ColumnsShape>(tableName: Table, fn?: ColumnsShapeCallback<CT, Shape>, dataFn?: TableDataFn<Shape, MaybeArray<TableDataItem>>): Promise<CreateTableResult<Table, Shape>>;
|
|
400
384
|
/**
|
|
401
385
|
* Drop the table, create it on rollback. See {@link createTable}.
|
|
402
386
|
*
|
|
403
387
|
* @param tableName - name of the table to drop
|
|
404
388
|
* @param options - {@link TableOptions}
|
|
405
389
|
* @param fn - create table callback
|
|
390
|
+
* @param dataFn - callback for creating composite indexes, primary keys, foreign keys
|
|
406
391
|
*/
|
|
407
|
-
dropTable<Table extends string, Shape extends ColumnsShape>(tableName: Table, options: TableOptions, fn?: ColumnsShapeCallback<CT, Shape
|
|
392
|
+
dropTable<Table extends string, Shape extends ColumnsShape>(tableName: Table, options: TableOptions, fn?: ColumnsShapeCallback<CT, Shape>, dataFn?: TableDataFn<Shape, MaybeArray<TableDataItem>>): Promise<CreateTableResult<Table, Shape>>;
|
|
408
393
|
/**
|
|
409
394
|
* `changeTable` accepts a table name, optional options, and a special callback with column changes.
|
|
410
395
|
*
|
|
@@ -501,7 +486,7 @@ declare class Migration<CT extends RakeDbColumnTypes> {
|
|
|
501
486
|
*/
|
|
502
487
|
addColumn(tableName: string, columnName: string, fn: (t: MigrationColumnTypes<CT>) => ColumnType): Promise<void>;
|
|
503
488
|
/**
|
|
504
|
-
* Drop the schema, create it on rollback. See {@link
|
|
489
|
+
* Drop the schema, create it on rollback. See {@link addColumn}.
|
|
505
490
|
*
|
|
506
491
|
* @param tableName - name of the table to add the column to
|
|
507
492
|
* @param columnName - name of the column to add
|
|
@@ -531,17 +516,17 @@ declare class Migration<CT extends RakeDbColumnTypes> {
|
|
|
531
516
|
*
|
|
532
517
|
* @param tableName - name of the table to add the index for
|
|
533
518
|
* @param columns - indexed columns
|
|
534
|
-
* @param
|
|
519
|
+
* @param args - index options, or an index name and then options
|
|
535
520
|
*/
|
|
536
|
-
addIndex(tableName: string, columns:
|
|
521
|
+
addIndex(tableName: string, columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], ...args: [options?: TableData.Index.OptionsArg] | [name?: string, options?: TableData.Index.OptionsArg]): Promise<void>;
|
|
537
522
|
/**
|
|
538
523
|
* Drop the schema, create it on rollback. See {@link addIndex}.
|
|
539
524
|
*
|
|
540
525
|
* @param tableName - name of the table to add the index for
|
|
541
526
|
* @param columns - indexed columns
|
|
542
|
-
* @param
|
|
527
|
+
* @param args - index options, or an index name and then options
|
|
543
528
|
*/
|
|
544
|
-
dropIndex(tableName: string, columns:
|
|
529
|
+
dropIndex(tableName: string, columns: (string | TableData.Index.ColumnOrExpressionOptions<string>)[], ...args: [options?: TableData.Index.OptionsArg] | [name?: string, options?: TableData.Index.OptionsArg]): Promise<void>;
|
|
545
530
|
/**
|
|
546
531
|
* Rename index:
|
|
547
532
|
*
|
|
@@ -602,7 +587,7 @@ declare class Migration<CT extends RakeDbColumnTypes> {
|
|
|
602
587
|
* @param foreignColumns - column names in the other table
|
|
603
588
|
* @param options - foreign key options
|
|
604
589
|
*/
|
|
605
|
-
addForeignKey(tableName: string, columns: [string, ...string[]], foreignTable: string, foreignColumns: [string, ...string[]], options?:
|
|
590
|
+
addForeignKey(tableName: string, columns: [string, ...string[]], foreignTable: string, foreignColumns: [string, ...string[]], options?: TableData.References.Options): Promise<void>;
|
|
606
591
|
/**
|
|
607
592
|
* Drop the schema, create it on rollback. See {@link addForeignKey}.
|
|
608
593
|
*
|
|
@@ -612,7 +597,7 @@ declare class Migration<CT extends RakeDbColumnTypes> {
|
|
|
612
597
|
* @param foreignColumns - column names in the other table
|
|
613
598
|
* @param options - foreign key options
|
|
614
599
|
*/
|
|
615
|
-
dropForeignKey(tableName: string, columns: [string, ...string[]], foreignTable: string, foreignColumns: [string, ...string[]], options?:
|
|
600
|
+
dropForeignKey(tableName: string, columns: [string, ...string[]], foreignTable: string, foreignColumns: [string, ...string[]], options?: TableData.References.Options): Promise<void>;
|
|
616
601
|
/**
|
|
617
602
|
* Add a primary key to a table on migrate, and remove it on rollback.
|
|
618
603
|
*
|
|
@@ -633,21 +618,17 @@ declare class Migration<CT extends RakeDbColumnTypes> {
|
|
|
633
618
|
*
|
|
634
619
|
* @param tableName - name of the table
|
|
635
620
|
* @param columns - array of the columns
|
|
636
|
-
* @param
|
|
621
|
+
* @param name - optionally, set a primary key constraint name
|
|
637
622
|
*/
|
|
638
|
-
addPrimaryKey(tableName: string, columns: string[],
|
|
639
|
-
name?: string;
|
|
640
|
-
}): Promise<void>;
|
|
623
|
+
addPrimaryKey(tableName: string, columns: [string, ...string[]], name?: string): Promise<void>;
|
|
641
624
|
/**
|
|
642
625
|
* Drop the schema, create it on rollback. See {@link addPrimaryKey}.
|
|
643
626
|
*
|
|
644
627
|
* @param tableName - name of the table
|
|
645
628
|
* @param columns - array of the columns
|
|
646
|
-
* @param
|
|
629
|
+
* @param name - optionally, set a primary key constraint name
|
|
647
630
|
*/
|
|
648
|
-
dropPrimaryKey(tableName: string, columns: string[],
|
|
649
|
-
name?: string;
|
|
650
|
-
}): Promise<void>;
|
|
631
|
+
dropPrimaryKey(tableName: string, columns: [string, ...string[]], name?: string): Promise<void>;
|
|
651
632
|
/**
|
|
652
633
|
* Add or drop a check for multiple columns.
|
|
653
634
|
*
|
|
@@ -664,42 +645,14 @@ declare class Migration<CT extends RakeDbColumnTypes> {
|
|
|
664
645
|
*/
|
|
665
646
|
addCheck(tableName: string, check: RawSQLBase): Promise<void>;
|
|
666
647
|
/**
|
|
667
|
-
* Drop the schema, create it on rollback. See {@link
|
|
648
|
+
* Drop the schema, create it on rollback. See {@link addCheck}.
|
|
668
649
|
*
|
|
669
650
|
* @param tableName - name of the table to add the check into
|
|
670
651
|
* @param check - raw SQL for the check
|
|
671
652
|
*/
|
|
672
653
|
dropCheck(tableName: string, check: RawSQLBase): Promise<void>;
|
|
673
654
|
/**
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
* See foreign key details in [foreign key](/guide/migration-column-methods.html#composite-foreign-key).
|
|
677
|
-
*
|
|
678
|
-
* ```ts
|
|
679
|
-
* import { change } from '../dbScript';
|
|
680
|
-
*
|
|
681
|
-
* change(async (db) => {
|
|
682
|
-
* await db.addConstraint('tableName', {
|
|
683
|
-
* name: 'constraintName',
|
|
684
|
-
* check: db.sql`column > 123`,
|
|
685
|
-
* references: [['id', 'name'], 'otherTable', ['otherId', 'otherName']],
|
|
686
|
-
* });
|
|
687
|
-
* });
|
|
688
|
-
* ```
|
|
689
|
-
*
|
|
690
|
-
* @param tableName - name of the table to add the constraint to
|
|
691
|
-
* @param constraint - constraint config object
|
|
692
|
-
*/
|
|
693
|
-
addConstraint(tableName: string, constraint: ConstraintArg): Promise<void>;
|
|
694
|
-
/**
|
|
695
|
-
* Drop the schema, create it on rollback. See {@link addConstraint}.
|
|
696
|
-
*
|
|
697
|
-
* @param tableName - name of the table to add the constraint to
|
|
698
|
-
* @param constraint - constraint config object
|
|
699
|
-
*/
|
|
700
|
-
dropConstraint(tableName: string, constraint: ConstraintArg): Promise<void>;
|
|
701
|
-
/**
|
|
702
|
-
* Rename a table constraint, such as primary key, or check.
|
|
655
|
+
* Rename a table constraint such as a primary key or a database check.
|
|
703
656
|
*
|
|
704
657
|
* ```ts
|
|
705
658
|
* import { change } from '../dbScript';
|
|
@@ -1231,14 +1184,23 @@ declare class Migration<CT extends RakeDbColumnTypes> {
|
|
|
1231
1184
|
*/
|
|
1232
1185
|
constraintExists(constraintName: string): Promise<boolean>;
|
|
1233
1186
|
}
|
|
1234
|
-
declare const renameType: (migration: Migration<
|
|
1187
|
+
declare const renameType: (migration: Migration<unknown>, from: string, to: string, kind: RakeDbAst.RenameType['kind']) => Promise<void>;
|
|
1235
1188
|
interface AddEnumValueOptions {
|
|
1236
1189
|
ifNotExists?: boolean;
|
|
1237
1190
|
before?: string;
|
|
1238
1191
|
after?: string;
|
|
1239
1192
|
}
|
|
1240
|
-
declare const addOrDropEnumValues: (migration: Migration<
|
|
1241
|
-
declare const changeEnumValues: (migration: Migration<
|
|
1193
|
+
declare const addOrDropEnumValues: (migration: Migration<unknown>, up: boolean, enumName: string, values: string[], options?: AddEnumValueOptions) => Promise<void>;
|
|
1194
|
+
declare const changeEnumValues: (migration: Migration<unknown>, enumName: string, fromValues: string[], toValues: string[]) => Promise<void>;
|
|
1195
|
+
|
|
1196
|
+
interface TableQuery {
|
|
1197
|
+
text: string;
|
|
1198
|
+
values?: unknown[];
|
|
1199
|
+
then?(result: QueryArraysResult): void;
|
|
1200
|
+
}
|
|
1201
|
+
interface CreateTableResult<Table extends string, Shape extends ColumnsShape> {
|
|
1202
|
+
table: Db$1<Table, Shape>;
|
|
1203
|
+
}
|
|
1242
1204
|
|
|
1243
1205
|
interface RakeDbCtx {
|
|
1244
1206
|
migrationsPromise?: Promise<MigrationsSet>;
|
|
@@ -1406,7 +1368,7 @@ type MigrationCallback = (arg: {
|
|
|
1406
1368
|
migrations: MigrationItem[];
|
|
1407
1369
|
}) => void | Promise<void>;
|
|
1408
1370
|
type AnyRakeDbConfig = RakeDbConfig<any, any>;
|
|
1409
|
-
type Db = DbResult<
|
|
1371
|
+
type Db = DbResult<unknown>;
|
|
1410
1372
|
interface RakeDbBaseTable<CT> {
|
|
1411
1373
|
exportAs: string;
|
|
1412
1374
|
getFilePath(): string;
|
|
@@ -1440,17 +1402,17 @@ declare const getDatabaseAndUserFromOptions: (options: AdapterOptions) => {
|
|
|
1440
1402
|
|
|
1441
1403
|
declare const createDb: <SchemaConfig extends ColumnSchemaConfig<orchid_core.ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any, orchid_core.CoreBaseOperators, unknown, unknown, any, unknown, any, orchid_core.ColumnDataBase>>, CT>(options: AdapterOptions[], config: RakeDbConfig<SchemaConfig, CT>) => Promise<void>;
|
|
1442
1404
|
declare const dropDb: <SchemaConfig extends ColumnSchemaConfig<orchid_core.ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any, orchid_core.CoreBaseOperators, unknown, unknown, any, unknown, any, orchid_core.ColumnDataBase>>, CT>(options: AdapterOptions[], config: RakeDbConfig<SchemaConfig, CT>) => Promise<void>;
|
|
1443
|
-
declare const resetDb: <SchemaConfig extends ColumnSchemaConfig<orchid_core.ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any, orchid_core.CoreBaseOperators, unknown, unknown, any, unknown, any, orchid_core.ColumnDataBase>>, CT
|
|
1405
|
+
declare const resetDb: <SchemaConfig extends ColumnSchemaConfig<orchid_core.ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any, orchid_core.CoreBaseOperators, unknown, unknown, any, unknown, any, orchid_core.ColumnDataBase>>, CT>(options: AdapterOptions[], config: RakeDbConfig<SchemaConfig, CT>) => Promise<void>;
|
|
1444
1406
|
|
|
1445
1407
|
declare const writeMigrationFile: (config: AnyRakeDbConfig, version: string, name: string, migrationCode: string) => Promise<void>;
|
|
1446
1408
|
declare const newMigration: (config: AnyRakeDbConfig, [name]: string[]) => Promise<void>;
|
|
1447
1409
|
declare const makeFileVersion: (ctx: RakeDbCtx, config: AnyRakeDbConfig) => Promise<string>;
|
|
1448
1410
|
declare const generateTimeStamp: () => string;
|
|
1449
1411
|
|
|
1450
|
-
type ChangeCallback<CT
|
|
1412
|
+
type ChangeCallback<CT> = (db: DbMigration<CT>, up: boolean) => Promise<void>;
|
|
1451
1413
|
declare const clearChanges: () => void;
|
|
1452
|
-
declare const getCurrentChanges: () => ChangeCallback<
|
|
1453
|
-
declare const pushChange: (fn: ChangeCallback<
|
|
1414
|
+
declare const getCurrentChanges: () => ChangeCallback<unknown>[];
|
|
1415
|
+
declare const pushChange: (fn: ChangeCallback<unknown>) => number;
|
|
1454
1416
|
|
|
1455
1417
|
declare const saveMigratedVersion: <SchemaConfig extends ColumnSchemaConfig<orchid_core.ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any, orchid_core.CoreBaseOperators, unknown, unknown, any, unknown, any, orchid_core.ColumnDataBase>>, CT>(db: SilentQueries, version: string, name: string, config: RakeDbConfig<SchemaConfig, CT>) => Promise<void>;
|
|
1456
1418
|
declare const deleteMigratedVersion: <SchemaConfig extends ColumnSchemaConfig<orchid_core.ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any, orchid_core.CoreBaseOperators, unknown, unknown, any, unknown, any, orchid_core.ColumnDataBase>>, CT>(db: SilentQueries, version: string, name: string, config: RakeDbConfig<SchemaConfig, CT>) => Promise<void>;
|
|
@@ -1463,7 +1425,7 @@ type RakeDbAppliedVersions = {
|
|
|
1463
1425
|
declare const getMigratedVersionsMap: <SchemaConfig extends ColumnSchemaConfig<orchid_core.ColumnTypeBase<orchid_core.ColumnTypeSchemaArg, unknown, any, orchid_core.CoreBaseOperators, unknown, unknown, any, unknown, any, orchid_core.ColumnDataBase>>, CT>(ctx: RakeDbCtx, adapter: Adapter | TransactionAdapter, config: RakeDbConfig<SchemaConfig, CT>, renameTo?: RakeDbMigrationId) => Promise<RakeDbAppliedVersions>;
|
|
1464
1426
|
|
|
1465
1427
|
declare const RAKE_DB_LOCK_KEY = "8582141715823621641";
|
|
1466
|
-
type MigrateFn = <SchemaConfig extends ColumnSchemaConfig, CT
|
|
1428
|
+
type MigrateFn = <SchemaConfig extends ColumnSchemaConfig, CT>(ctx: RakeDbCtx, options: AdapterOptions[], config: RakeDbConfig<SchemaConfig, CT>, args?: string[], adapters?: Adapter[], dontClose?: boolean) => Promise<Adapter[]>;
|
|
1467
1429
|
/**
|
|
1468
1430
|
* Will run all pending yet migrations, sequentially in order,
|
|
1469
1431
|
* will apply `change` functions top-to-bottom.
|
|
@@ -1486,8 +1448,8 @@ declare const rollback: MigrateFn;
|
|
|
1486
1448
|
* Takes the same options as {@link migrate}.
|
|
1487
1449
|
*/
|
|
1488
1450
|
declare const redo: MigrateFn;
|
|
1489
|
-
declare const migrateOrRollback: (trx: TransactionAdapter, config: RakeDbConfig<ColumnSchemaConfig,
|
|
1490
|
-
declare const changeCache: Record<string, ChangeCallback<
|
|
1451
|
+
declare const migrateOrRollback: (trx: TransactionAdapter, config: RakeDbConfig<ColumnSchemaConfig, unknown>, set: MigrationsSet, versions: RakeDbAppliedVersions, count: number, up: boolean, redo: boolean, force?: boolean, skipLock?: boolean) => Promise<void>;
|
|
1452
|
+
declare const changeCache: Record<string, ChangeCallback<unknown>[] | undefined>;
|
|
1491
1453
|
|
|
1492
1454
|
declare namespace DbStructure {
|
|
1493
1455
|
interface Table {
|
|
@@ -1708,7 +1670,7 @@ declare const getIndexName: (table: string, columns: ({
|
|
|
1708
1670
|
} | {
|
|
1709
1671
|
expression: string;
|
|
1710
1672
|
})[]) => string;
|
|
1711
|
-
declare const indexesToQuery: (up: boolean, { schema, name }: {
|
|
1673
|
+
declare const indexesToQuery: (up: boolean, { schema, name: tableName }: {
|
|
1712
1674
|
schema?: string;
|
|
1713
1675
|
name: string;
|
|
1714
1676
|
}, indexes: TableData.Index[], language?: string) => Sql[];
|
|
@@ -1721,7 +1683,7 @@ declare const primaryKeyToSql: (primaryKey: Exclude<TableData['primaryKey'], und
|
|
|
1721
1683
|
/**
|
|
1722
1684
|
* Type of {@link rakeDb} function
|
|
1723
1685
|
*/
|
|
1724
|
-
type RakeDbFn = (<SchemaConfig extends ColumnSchemaConfig, CT
|
|
1686
|
+
type RakeDbFn = (<SchemaConfig extends ColumnSchemaConfig, CT>(options: MaybeArray<AdapterOptions>, partialConfig?: InputRakeDbConfig<SchemaConfig, CT>, args?: string[]) => RakeDbFnReturns<CT>) & {
|
|
1725
1687
|
/**
|
|
1726
1688
|
* Unlike the original `rakeDb` that executes immediately,
|
|
1727
1689
|
* `rakeDb.lazy` returns the `run` function to be later called programmatically.
|
|
@@ -1732,7 +1694,7 @@ type RakeDbFn = (<SchemaConfig extends ColumnSchemaConfig, CT extends RakeDbColu
|
|
|
1732
1694
|
*/
|
|
1733
1695
|
lazy: RakeDbLazyFn;
|
|
1734
1696
|
};
|
|
1735
|
-
type RakeDbFnReturns<CT
|
|
1697
|
+
type RakeDbFnReturns<CT> = RakeDbChangeFn<CT extends undefined ? DefaultColumnTypes<DefaultSchemaConfig> : CT> & {
|
|
1736
1698
|
promise: Promise<RakeDbResult>;
|
|
1737
1699
|
};
|
|
1738
1700
|
interface RakeDbResult {
|
|
@@ -1743,7 +1705,7 @@ interface RakeDbResult {
|
|
|
1743
1705
|
/**
|
|
1744
1706
|
* Type of {@link rakeDb.lazy} function
|
|
1745
1707
|
*/
|
|
1746
|
-
type RakeDbLazyFn = <SchemaConfig extends ColumnSchemaConfig, CT
|
|
1708
|
+
type RakeDbLazyFn = <SchemaConfig extends ColumnSchemaConfig, CT>(options: MaybeArray<AdapterOptions>, partialConfig?: InputRakeDbConfig<SchemaConfig, CT>) => {
|
|
1747
1709
|
change: RakeDbChangeFn<CT>;
|
|
1748
1710
|
run(args: string[], config?: Partial<RakeDbConfig<SchemaConfig, CT>>): Promise<RakeDbResult>;
|
|
1749
1711
|
};
|
|
@@ -1752,7 +1714,7 @@ type RakeDbLazyFn = <SchemaConfig extends ColumnSchemaConfig, CT extends RakeDbC
|
|
|
1752
1714
|
* Saves the given callback to an internal queue,
|
|
1753
1715
|
* and also returns the callback in case you want to export it from migration.
|
|
1754
1716
|
*/
|
|
1755
|
-
type RakeDbChangeFn<CT
|
|
1717
|
+
type RakeDbChangeFn<CT> = (fn: ChangeCallback<CT>) => ChangeCallback<CT>;
|
|
1756
1718
|
/**
|
|
1757
1719
|
* Function to configure and run `rakeDb`.
|
|
1758
1720
|
*
|
|
@@ -1802,4 +1764,4 @@ declare const promptText: ({ message, default: def, password, min, }: {
|
|
|
1802
1764
|
min?: number;
|
|
1803
1765
|
}) => Promise<string>;
|
|
1804
1766
|
|
|
1805
|
-
export { AnyRakeDbConfig, ChangeCallback, ChangeTableCallback, ChangeTableOptions, ColumnComment, ColumnsShapeCallback, CommandFn,
|
|
1767
|
+
export { AnyRakeDbConfig, ChangeCallback, ChangeTableCallback, ChangeTableOptions, ColumnComment, ColumnsShapeCallback, CommandFn, DbMigration, DbStructure, DbStructureDomainsMap, DropMode, InputRakeDbConfig, IntrospectedStructure, Migration, MigrationAdapter, MigrationColumnTypes, ModuleExportsRecord, NoMigrationsTableError, RAKE_DB_LOCK_KEY, RakeDbAppliedVersions, RakeDbAst, RakeDbBaseTable, RakeDbChangeFn, RakeDbConfig, RakeDbCtx, RakeDbFn, RakeDbFnReturns, RakeDbLazyFn, RakeDbMigrationId, RakeDbResult, SilentQueries, StructureToAstCtx, StructureToAstTableData, TableOptions, addColumnComment, addColumnIndex, addOrDropEnumValues, astToMigration, changeCache, changeEnumValues, clearChanges, colors, columnToSql, columnTypeToSql, commentsToQuery, concatSchemaAndName, constraintToSql, createDb, createMigrationInterface, dbColumnToAst, deleteMigratedVersion, dropDb, encodeColumnDefault, exhaustive, generateTimeStamp, getColumnName, getConstraintName, getCurrentChanges, getDatabaseAndUserFromOptions, getDbStructureTableData, getDbTableColumnsChecks, getFirstWordAndRest, getForeignKeyTable, getIndexName, getMigratedVersionsMap, getSchemaAndTableFromName, getTextAfterFrom, getTextAfterTo, identityToSql, indexesToQuery, instantiateDbColumn, introspectDbSchema, joinColumns, joinWords, makeDbStructureColumnsShape, makeDomainsMap, makeFileVersion, makePopulateEnumQuery, makeStructureToAstCtx, migrate, migrateOrRollback, migrationConfigDefaults, newMigration, pluralize, primaryKeyToSql, processRakeDbConfig, promptConfirm, promptSelect, promptText, pushChange, queryLock, quoteNameFromString, quoteSchemaTable, quoteTable, quoteWithSchema, rakeDb, rakeDbAliases, rakeDbCommands, redo, referencesToSql, renameType, resetDb, rollback, saveMigratedVersion, structureToAst, tableToAst, transaction, versionToString, writeMigrationFile };
|