rake-db 2.4.30 → 2.4.33
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 -5
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +9 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnType, EnumColumn, ColumnTypes, ColumnsShape, DbResult, DefaultColumnTypes, TransactionAdapter, QueryLogObject, IndexColumnOptions, IndexOptions, ForeignKeyOptions, TextColumn, NoPrimaryKeyOption, TableData, SingleColumnIndexOptions, AdapterOptions, QueryLogOptions
|
|
1
|
+
import { ColumnType, EnumColumn, ColumnTypes, ColumnsShape, 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
4
|
declare function add(this: ColumnTypesBase, item: ColumnType, options?: {
|
|
@@ -54,7 +54,13 @@ declare type ColumnComment = {
|
|
|
54
54
|
column: string;
|
|
55
55
|
comment: string | null;
|
|
56
56
|
};
|
|
57
|
-
declare type
|
|
57
|
+
declare type SilentQueries = {
|
|
58
|
+
silentQuery: Adapter['query'];
|
|
59
|
+
silentArrays: Adapter['arrays'];
|
|
60
|
+
};
|
|
61
|
+
declare type Migration = DbResult<DefaultColumnTypes> & MigrationBase & {
|
|
62
|
+
adapter: SilentQueries;
|
|
63
|
+
};
|
|
58
64
|
declare type ConstraintArg = {
|
|
59
65
|
name?: string;
|
|
60
66
|
references?: [
|
|
@@ -264,8 +270,8 @@ declare const redo: (options: MaybeArray<AdapterOptions>, config: RakeDbConfig,
|
|
|
264
270
|
|
|
265
271
|
declare const rakeDb: (options: MaybeArray<AdapterOptions>, partialConfig?: Partial<RakeDbConfig>, args?: string[]) => Promise<void>;
|
|
266
272
|
|
|
267
|
-
declare const saveMigratedVersion: (db:
|
|
268
|
-
declare const removeMigratedVersion: (db:
|
|
273
|
+
declare const saveMigratedVersion: (db: SilentQueries, version: string, config: RakeDbConfig) => Promise<void>;
|
|
274
|
+
declare const removeMigratedVersion: (db: SilentQueries, version: string, config: RakeDbConfig) => Promise<void>;
|
|
269
275
|
declare const getMigratedVersionsMap: (db: Adapter, config: RakeDbConfig) => Promise<Record<string, boolean>>;
|
|
270
276
|
|
|
271
|
-
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 };
|
|
277
|
+
export { AppCodeUpdater, ChangeTableCallback, ChangeTableOptions, ColumnComment, ColumnsShapeCallback, DropMode, Migration, MigrationBase, MigrationColumnTypes, RakeDbAst, RakeDbConfig, SilentQueries, TableOptions, change, changeCache, createDb, createMigrationInterface, dropDb, generate, getMigratedVersionsMap, makeFileTimeStamp, migrate, migrateOrRollback, rakeDb, redo, removeMigratedVersion, resetDb, rollback, saveMigratedVersion, writeMigrationFile };
|
package/dist/index.js
CHANGED
|
@@ -472,6 +472,9 @@ const indexesToQuery = (up, { schema, name }, indexes) => {
|
|
|
472
472
|
`INCLUDE (${orchidCore.toArray(options.include).map((column) => `"${column}"`).join(", ")})`
|
|
473
473
|
);
|
|
474
474
|
}
|
|
475
|
+
if (options.nullsNotDistinct) {
|
|
476
|
+
sql.push(`NULLS NOT DISTINCT`);
|
|
477
|
+
}
|
|
475
478
|
if (options.with) {
|
|
476
479
|
sql.push(`WITH (${options.with})`);
|
|
477
480
|
}
|
|
@@ -1194,6 +1197,7 @@ const createMigrationInterface = (tx, up, options) => {
|
|
|
1194
1197
|
adapter.arrays = (q, types) => {
|
|
1195
1198
|
return wrapWithLog(log, q, () => arrays.call(adapter, q, types));
|
|
1196
1199
|
};
|
|
1200
|
+
Object.assign(adapter, { silentQuery: query, silentArrays: arrays });
|
|
1197
1201
|
const db = pqb.createDb({ adapter });
|
|
1198
1202
|
const { prototype: proto } = MigrationBase;
|
|
1199
1203
|
for (const key of Object.getOwnPropertyNames(proto)) {
|
|
@@ -1457,14 +1461,14 @@ const queryExists = (db, sql) => {
|
|
|
1457
1461
|
};
|
|
1458
1462
|
|
|
1459
1463
|
const saveMigratedVersion = async (db, version, config) => {
|
|
1460
|
-
await db.
|
|
1464
|
+
await db.silentArrays(
|
|
1461
1465
|
`INSERT INTO ${quoteWithSchema({
|
|
1462
1466
|
name: config.migrationsTable
|
|
1463
1467
|
})} VALUES ('${version}')`
|
|
1464
1468
|
);
|
|
1465
1469
|
};
|
|
1466
1470
|
const removeMigratedVersion = async (db, version, config) => {
|
|
1467
|
-
await db.
|
|
1471
|
+
await db.silentArrays(
|
|
1468
1472
|
`DELETE FROM ${quoteWithSchema({
|
|
1469
1473
|
name: config.migrationsTable
|
|
1470
1474
|
})} WHERE version = '${version}'`
|
|
@@ -1965,6 +1969,7 @@ ORDER BY c.ordinal_position`
|
|
|
1965
1969
|
)
|
|
1966
1970
|
FROM unnest(i.indkey[indnkeyatts:]) AS j(e)
|
|
1967
1971
|
) AS "include",
|
|
1972
|
+
(to_jsonb(i.*)->'indnullsnotdistinct')::bool AS "nullsNotDistinct",
|
|
1968
1973
|
NULLIF(pg_catalog.array_to_string(
|
|
1969
1974
|
ic.reloptions || array(SELECT 'toast.' || x FROM pg_catalog.unnest(tc.reloptions) x),
|
|
1970
1975
|
', '
|
|
@@ -2461,6 +2466,7 @@ const pushTableAst = (ctx, ast, data, domains, table, pendingTables, innerConstr
|
|
|
2461
2466
|
using: index.using === "btree" ? void 0 : index.using,
|
|
2462
2467
|
unique: index.isUnique,
|
|
2463
2468
|
include: index.include,
|
|
2469
|
+
nullsNotDistinct: index.nullsNotDistinct,
|
|
2464
2470
|
with: index.with,
|
|
2465
2471
|
tablespace: index.tablespace,
|
|
2466
2472
|
where: index.where
|
|
@@ -2513,6 +2519,7 @@ const pushTableAst = (ctx, ast, data, domains, table, pendingTables, innerConstr
|
|
|
2513
2519
|
using: index.using === "btree" ? void 0 : index.using,
|
|
2514
2520
|
unique: index.isUnique,
|
|
2515
2521
|
include: index.include,
|
|
2522
|
+
nullsNotDistinct: index.nullsNotDistinct,
|
|
2516
2523
|
with: index.with,
|
|
2517
2524
|
tablespace: index.tablespace,
|
|
2518
2525
|
where: index.where
|