rake-db 2.4.35 → 2.4.37
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 +11 -7
- package/dist/index.js +10 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { ColumnType, EnumColumn, ColumnTypes,
|
|
1
|
+
import { ColumnsShape, Db as Db$1, ColumnType, EnumColumn, ColumnTypes, Adapter, DbResult, DefaultColumnTypes, TransactionAdapter, QueryLogObject, IndexColumnOptions, IndexOptions, ForeignKeyOptions, TextColumn, NoPrimaryKeyOption, TableData, SingleColumnIndexOptions, AdapterOptions, QueryLogOptions } from 'pqb';
|
|
2
2
|
import { EmptyObject, RawExpression, ColumnTypesBase, raw, MaybeArray } from 'orchid-core';
|
|
3
3
|
|
|
4
|
+
declare type CreateTableResult<Table extends string, Shape extends ColumnsShape> = {
|
|
5
|
+
table: Db$1<Table, Shape>;
|
|
6
|
+
};
|
|
7
|
+
|
|
4
8
|
declare function add(this: ColumnTypesBase, item: ColumnType, options?: {
|
|
5
9
|
dropMode?: DropMode;
|
|
6
10
|
}): RakeDbAst.ChangeTableItem.Column;
|
|
@@ -42,9 +46,9 @@ declare type MigrationColumnTypes = Omit<ColumnTypes, 'text' | 'string' | 'enum'
|
|
|
42
46
|
citext: TextColumnCreator;
|
|
43
47
|
enum: (name: string) => EnumColumn;
|
|
44
48
|
};
|
|
45
|
-
declare type ColumnsShapeCallback = (t: MigrationColumnTypes & {
|
|
49
|
+
declare type ColumnsShapeCallback<Shape extends ColumnsShape = ColumnsShape> = (t: MigrationColumnTypes & {
|
|
46
50
|
raw: typeof raw;
|
|
47
|
-
}) =>
|
|
51
|
+
}) => Shape;
|
|
48
52
|
declare type ChangeTableOptions = {
|
|
49
53
|
snakeCase?: boolean;
|
|
50
54
|
comment?: string | [string, string] | null;
|
|
@@ -79,10 +83,10 @@ declare class MigrationBase {
|
|
|
79
83
|
up: boolean;
|
|
80
84
|
options: RakeDbConfig;
|
|
81
85
|
migratedAsts: RakeDbAst[];
|
|
82
|
-
createTable(tableName:
|
|
83
|
-
createTable(tableName:
|
|
84
|
-
dropTable(tableName:
|
|
85
|
-
dropTable(tableName:
|
|
86
|
+
createTable<Table extends string, Shape extends ColumnsShape>(tableName: Table, options: TableOptions, fn: ColumnsShapeCallback<Shape>): Promise<CreateTableResult<Table, Shape>>;
|
|
87
|
+
createTable<Table extends string, Shape extends ColumnsShape>(tableName: Table, fn: ColumnsShapeCallback<Shape>): Promise<CreateTableResult<Table, Shape>>;
|
|
88
|
+
dropTable<Table extends string, Shape extends ColumnsShape>(tableName: Table, options: TableOptions, fn: ColumnsShapeCallback<Shape>): Promise<CreateTableResult<Table, Shape>>;
|
|
89
|
+
dropTable<Table extends string, Shape extends ColumnsShape>(tableName: Table, fn: ColumnsShapeCallback<Shape>): Promise<CreateTableResult<Table, Shape>>;
|
|
86
90
|
changeTable(tableName: string, options: ChangeTableOptions, fn?: ChangeTableCallback): Promise<void>;
|
|
87
91
|
changeTable(tableName: string, fn: ChangeTableCallback): Promise<void>;
|
|
88
92
|
renameTable(from: string, to: string): Promise<void>;
|
package/dist/index.js
CHANGED
|
@@ -569,6 +569,15 @@ const createTable$1 = async (migration, up, tableName, options, fn) => {
|
|
|
569
569
|
then == null ? void 0 : then(result);
|
|
570
570
|
}
|
|
571
571
|
migration.migratedAsts.push(ast);
|
|
572
|
+
let table;
|
|
573
|
+
return {
|
|
574
|
+
get table() {
|
|
575
|
+
return table != null ? table : table = migration(tableName, shape, {
|
|
576
|
+
noPrimaryKey: options.noPrimaryKey ? "ignore" : void 0,
|
|
577
|
+
snakeCase: options.snakeCase
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
};
|
|
572
581
|
};
|
|
573
582
|
const makeAst$1 = (up, tableName, shape, tableData, options, noPrimaryKey) => {
|
|
574
583
|
const shapePKeys = [];
|
|
@@ -2257,7 +2266,7 @@ const structureToAst = async (ctx, db) => {
|
|
|
2257
2266
|
baseType: domains[`${it.schemaName}.${it.name}`],
|
|
2258
2267
|
notNull: it.notNull,
|
|
2259
2268
|
collation: it.collation,
|
|
2260
|
-
default:
|
|
2269
|
+
default: pqb.simplifyColumnDefault(it.default),
|
|
2261
2270
|
check: it.check ? orchidCore.raw(it.check) : void 0
|
|
2262
2271
|
});
|
|
2263
2272
|
}
|