rake-db 2.29.10 → 2.30.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/index.d.ts +217 -179
- package/dist/index.js +428 -153
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +428 -153
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,190 @@
|
|
|
1
1
|
import * as pqb from 'pqb';
|
|
2
|
-
import { TableData, ColumnsShape, NoPrimaryKeyOption, MaybeArray, Column, RawSqlBase, RecordString, EnumColumn, EmptyObject,
|
|
2
|
+
import { SearchWeight, RecordOptionalString, AdapterBase, TableData, ColumnsShape, NoPrimaryKeyOption, MaybeArray, Column, RawSqlBase, RecordString, EnumColumn, EmptyObject, DbResult, DefaultColumnTypes, DefaultSchemaConfig, QueryLogObject, TableDataFn, TableDataItem, DbDomainArg, ColumnSchemaConfig, raw, Db, QuerySchema, MaybePromise, QueryLogOptions, QueryLogger, ColumnsByType, DbStructureDomainsMap } from 'pqb';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
declare namespace DbStructure {
|
|
5
|
+
interface TableNameAndSchemaName {
|
|
6
|
+
schemaName: string;
|
|
7
|
+
tableName: string;
|
|
8
|
+
}
|
|
9
|
+
interface Table {
|
|
10
|
+
schemaName: string;
|
|
11
|
+
name: string;
|
|
12
|
+
comment?: string;
|
|
13
|
+
columns: Column[];
|
|
14
|
+
}
|
|
15
|
+
interface View {
|
|
16
|
+
schemaName: string;
|
|
17
|
+
name: string;
|
|
18
|
+
deps: RakeDbAst.View['deps'];
|
|
19
|
+
isRecursive: boolean;
|
|
20
|
+
with?: string[];
|
|
21
|
+
columns: Column[];
|
|
22
|
+
sql: string;
|
|
23
|
+
}
|
|
24
|
+
interface Procedure {
|
|
25
|
+
schemaName: string;
|
|
26
|
+
name: string;
|
|
27
|
+
returnSet: boolean;
|
|
28
|
+
returnType: string;
|
|
29
|
+
kind: string;
|
|
30
|
+
isTrigger: boolean;
|
|
31
|
+
types: string[];
|
|
32
|
+
argTypes: string[];
|
|
33
|
+
argModes: ('i' | 'o')[];
|
|
34
|
+
argNames?: string[];
|
|
35
|
+
}
|
|
36
|
+
interface Column extends TableNameAndSchemaName {
|
|
37
|
+
name: string;
|
|
38
|
+
typeSchema: string;
|
|
39
|
+
type: string;
|
|
40
|
+
arrayDims: number;
|
|
41
|
+
maxChars?: number;
|
|
42
|
+
numericPrecision?: number;
|
|
43
|
+
numericScale?: number;
|
|
44
|
+
dateTimePrecision?: number;
|
|
45
|
+
default?: string;
|
|
46
|
+
isNullable: boolean;
|
|
47
|
+
collate?: string;
|
|
48
|
+
compression?: 'pglz' | 'lz4';
|
|
49
|
+
comment?: string;
|
|
50
|
+
identity?: {
|
|
51
|
+
always: boolean;
|
|
52
|
+
start: number;
|
|
53
|
+
increment: number;
|
|
54
|
+
min?: number;
|
|
55
|
+
max?: number;
|
|
56
|
+
cache: number;
|
|
57
|
+
cycle: boolean;
|
|
58
|
+
};
|
|
59
|
+
extension?: string;
|
|
60
|
+
typmod: number;
|
|
61
|
+
}
|
|
62
|
+
interface Index extends TableNameAndSchemaName {
|
|
63
|
+
name: string;
|
|
64
|
+
using: string;
|
|
65
|
+
unique: boolean;
|
|
66
|
+
columns: (({
|
|
67
|
+
column: string;
|
|
68
|
+
} | {
|
|
69
|
+
expression: string;
|
|
70
|
+
}) & {
|
|
71
|
+
collate?: string;
|
|
72
|
+
opclass?: string;
|
|
73
|
+
order?: string;
|
|
74
|
+
weight?: SearchWeight;
|
|
75
|
+
})[];
|
|
76
|
+
include?: string[];
|
|
77
|
+
nullsNotDistinct?: boolean;
|
|
78
|
+
with?: string;
|
|
79
|
+
tablespace?: string;
|
|
80
|
+
where?: string;
|
|
81
|
+
tsVector?: boolean;
|
|
82
|
+
language?: string;
|
|
83
|
+
languageColumn?: string;
|
|
84
|
+
}
|
|
85
|
+
interface Exclude extends Index {
|
|
86
|
+
exclude: string[];
|
|
87
|
+
}
|
|
88
|
+
type ForeignKeyMatch = 'f' | 'p' | 's';
|
|
89
|
+
type ForeignKeyAction = 'a' | 'r' | 'c' | 'n' | 'd';
|
|
90
|
+
interface Constraint extends TableNameAndSchemaName {
|
|
91
|
+
name: string;
|
|
92
|
+
primaryKey?: string[];
|
|
93
|
+
references?: References;
|
|
94
|
+
check?: Check;
|
|
95
|
+
}
|
|
96
|
+
interface References {
|
|
97
|
+
foreignSchema: string;
|
|
98
|
+
foreignTable: string;
|
|
99
|
+
columns: string[];
|
|
100
|
+
foreignColumns: string[];
|
|
101
|
+
match: ForeignKeyMatch;
|
|
102
|
+
onUpdate: ForeignKeyAction;
|
|
103
|
+
onDelete: ForeignKeyAction;
|
|
104
|
+
}
|
|
105
|
+
interface Check {
|
|
106
|
+
columns?: string[];
|
|
107
|
+
expression: string;
|
|
108
|
+
}
|
|
109
|
+
interface Trigger extends TableNameAndSchemaName {
|
|
110
|
+
triggerSchema: string;
|
|
111
|
+
name: string;
|
|
112
|
+
events: string[];
|
|
113
|
+
activation: string;
|
|
114
|
+
condition?: string;
|
|
115
|
+
definition: string;
|
|
116
|
+
}
|
|
117
|
+
interface Extension {
|
|
118
|
+
schemaName: string;
|
|
119
|
+
name: string;
|
|
120
|
+
version?: string;
|
|
121
|
+
}
|
|
122
|
+
interface Enum {
|
|
123
|
+
schemaName: string;
|
|
124
|
+
name: string;
|
|
125
|
+
values: [string, ...string[]];
|
|
126
|
+
}
|
|
127
|
+
interface Domain {
|
|
128
|
+
schemaName: string;
|
|
129
|
+
name: string;
|
|
130
|
+
type: string;
|
|
131
|
+
typeSchema: string;
|
|
132
|
+
arrayDims: number;
|
|
133
|
+
isNullable: boolean;
|
|
134
|
+
maxChars?: number;
|
|
135
|
+
numericPrecision?: number;
|
|
136
|
+
numericScale?: number;
|
|
137
|
+
dateTimePrecision?: number;
|
|
138
|
+
collate?: string;
|
|
139
|
+
default?: string;
|
|
140
|
+
checks?: string[];
|
|
141
|
+
}
|
|
142
|
+
interface Collation {
|
|
143
|
+
schemaName: string;
|
|
144
|
+
name: string;
|
|
145
|
+
provider: string;
|
|
146
|
+
deterministic: boolean;
|
|
147
|
+
lcCollate?: string;
|
|
148
|
+
lcCType?: string;
|
|
149
|
+
locale?: string;
|
|
150
|
+
version?: string;
|
|
151
|
+
}
|
|
152
|
+
interface Role {
|
|
153
|
+
name: string;
|
|
154
|
+
super: boolean;
|
|
155
|
+
inherit: boolean;
|
|
156
|
+
createRole: boolean;
|
|
157
|
+
createDb: boolean;
|
|
158
|
+
canLogin: boolean;
|
|
159
|
+
replication: boolean;
|
|
160
|
+
connLimit: number;
|
|
161
|
+
validUntil?: Date;
|
|
162
|
+
bypassRls: boolean;
|
|
163
|
+
config?: RecordOptionalString;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
interface IntrospectedStructure {
|
|
167
|
+
schemas: string[];
|
|
168
|
+
tables: DbStructure.Table[];
|
|
169
|
+
views: DbStructure.View[];
|
|
170
|
+
indexes: DbStructure.Index[];
|
|
171
|
+
excludes: DbStructure.Exclude[];
|
|
172
|
+
constraints: DbStructure.Constraint[];
|
|
173
|
+
triggers: DbStructure.Trigger[];
|
|
174
|
+
extensions: DbStructure.Extension[];
|
|
175
|
+
enums: DbStructure.Enum[];
|
|
176
|
+
domains: DbStructure.Domain[];
|
|
177
|
+
collations: DbStructure.Collation[];
|
|
178
|
+
roles?: DbStructure.Role[];
|
|
179
|
+
}
|
|
180
|
+
interface IntrospectDbStructureParams {
|
|
181
|
+
roles?: {
|
|
182
|
+
whereSql?: string;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
declare function introspectDbSchema(db: AdapterBase, params?: IntrospectDbStructureParams): Promise<IntrospectedStructure>;
|
|
186
|
+
|
|
187
|
+
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 | RakeDbAst.Role | RakeDbAst.ChangeRole;
|
|
5
188
|
declare namespace RakeDbAst {
|
|
6
189
|
interface Table extends TableData {
|
|
7
190
|
type: 'table';
|
|
@@ -192,6 +375,16 @@ declare namespace RakeDbAst {
|
|
|
192
375
|
securityInvoker?: boolean;
|
|
193
376
|
};
|
|
194
377
|
}
|
|
378
|
+
interface Role extends DbStructure.Role {
|
|
379
|
+
type: 'role';
|
|
380
|
+
action: 'create' | 'drop';
|
|
381
|
+
}
|
|
382
|
+
interface ChangeRole {
|
|
383
|
+
type: 'changeRole';
|
|
384
|
+
name: string;
|
|
385
|
+
from: Partial<DbStructure.Role>;
|
|
386
|
+
to: Partial<DbStructure.Role>;
|
|
387
|
+
}
|
|
195
388
|
}
|
|
196
389
|
|
|
197
390
|
declare function add(item: Column, options?: {
|
|
@@ -291,10 +484,10 @@ type ChangeTableOptions = {
|
|
|
291
484
|
comment?: string | [string, string] | null;
|
|
292
485
|
};
|
|
293
486
|
type ChangeTableCallback<CT> = (t: TableChanger<CT>) => TableChangeData;
|
|
294
|
-
|
|
487
|
+
interface SilentQueries extends AdapterBase {
|
|
295
488
|
silentQuery: AdapterBase['query'];
|
|
296
489
|
silentArrays: AdapterBase['arrays'];
|
|
297
|
-
}
|
|
490
|
+
}
|
|
298
491
|
type DbMigration<CT> = DbResult<CT> & Migration<CT> & {
|
|
299
492
|
adapter: SilentQueries;
|
|
300
493
|
};
|
|
@@ -1210,6 +1403,12 @@ declare class Migration<CT = unknown> {
|
|
|
1210
1403
|
* @param constraintName - name of the constraint
|
|
1211
1404
|
*/
|
|
1212
1405
|
constraintExists(constraintName: string): Promise<boolean>;
|
|
1406
|
+
createRole(name: string, params: Partial<DbStructure.Role>): Promise<void>;
|
|
1407
|
+
dropRole(name: string, params?: Partial<DbStructure.Role>): Promise<void>;
|
|
1408
|
+
changeRole(name: string, params: {
|
|
1409
|
+
from?: Partial<DbStructure.Role>;
|
|
1410
|
+
to: Partial<DbStructure.Role>;
|
|
1411
|
+
}): Promise<void>;
|
|
1213
1412
|
}
|
|
1214
1413
|
interface AddEnumValueOptions {
|
|
1215
1414
|
ifNotExists?: boolean;
|
|
@@ -1224,7 +1423,7 @@ interface CreateTableResult<Table extends string, Shape extends ColumnsShape> {
|
|
|
1224
1423
|
interface RakeDbCtx {
|
|
1225
1424
|
migrationsPromise?: Promise<MigrationsSet>;
|
|
1226
1425
|
}
|
|
1227
|
-
declare const getSchemaAndTableFromName: (
|
|
1426
|
+
declare const getSchemaAndTableFromName: (schema: QuerySchema | undefined, name: string) => [string | undefined, string];
|
|
1228
1427
|
declare const concatSchemaAndName: ({ schema, name, }: {
|
|
1229
1428
|
schema?: string;
|
|
1230
1429
|
name: string;
|
|
@@ -1248,6 +1447,7 @@ interface MigrationsSet {
|
|
|
1248
1447
|
migrations: MigrationItem[];
|
|
1249
1448
|
}
|
|
1250
1449
|
|
|
1450
|
+
type SearchPath = (() => string) | string;
|
|
1251
1451
|
interface RakeDbCliConfigInputBase<SchemaConfig extends ColumnSchemaConfig, CT = DefaultColumnTypes<DefaultSchemaConfig>> extends QueryLogOptions {
|
|
1252
1452
|
columnTypes?: CT | ((t: DefaultColumnTypes<DefaultSchemaConfig>) => CT);
|
|
1253
1453
|
baseTable?: RakeDbBaseTable<CT>;
|
|
@@ -1263,6 +1463,12 @@ interface RakeDbCliConfigInputBase<SchemaConfig extends ColumnSchemaConfig, CT =
|
|
|
1263
1463
|
[commandName: string]: RakeDbCommandFn | RakeDbCommand;
|
|
1264
1464
|
};
|
|
1265
1465
|
noPrimaryKey?: NoPrimaryKeyOption;
|
|
1466
|
+
transactionSearchPath?: SearchPath;
|
|
1467
|
+
/**
|
|
1468
|
+
* Throw if a migration doesn't have a default export.
|
|
1469
|
+
* This is needed when in your setup you're importing migration files first and execute them later,
|
|
1470
|
+
* in that case you should export changes in migrations.
|
|
1471
|
+
*/
|
|
1266
1472
|
forceDefaultExports?: boolean;
|
|
1267
1473
|
/**
|
|
1268
1474
|
* Is called once per db before migrating or rolling back a set of migrations.
|
|
@@ -1347,11 +1553,6 @@ interface RakeDbConfig<ColumnTypes = unknown> extends QueryLogOptions {
|
|
|
1347
1553
|
*/
|
|
1348
1554
|
__rakeDbConfig: true;
|
|
1349
1555
|
migrationsTable: string;
|
|
1350
|
-
/**
|
|
1351
|
-
* by default, all the migrated tables and the special table for tracking migrations are created in `public`.
|
|
1352
|
-
* set this `schema` setting to use create everything in this schema instead.
|
|
1353
|
-
*/
|
|
1354
|
-
schema?: QuerySchema;
|
|
1355
1556
|
recurrentPath?: string;
|
|
1356
1557
|
columnTypes: ColumnTypes;
|
|
1357
1558
|
beforeChange?: ChangeCallback$1;
|
|
@@ -1361,6 +1562,7 @@ interface RakeDbConfig<ColumnTypes = unknown> extends QueryLogOptions {
|
|
|
1361
1562
|
beforeRollback?: MigrationCallback;
|
|
1362
1563
|
afterRollback?: MigrationCallback;
|
|
1363
1564
|
migrationId: RakeDbMigrationId;
|
|
1565
|
+
transactionSearchPath?: SearchPath;
|
|
1364
1566
|
forceDefaultExports?: boolean;
|
|
1365
1567
|
afterChangeCommit?: ChangeCommitCallback;
|
|
1366
1568
|
basePath: string;
|
|
@@ -1496,8 +1698,7 @@ interface GetIndexOrExcludeName {
|
|
|
1496
1698
|
}
|
|
1497
1699
|
declare const getIndexName: GetIndexOrExcludeName;
|
|
1498
1700
|
declare const getExcludeName: GetIndexOrExcludeName;
|
|
1499
|
-
declare const getMigrationsSchemaAndTable: (config: {
|
|
1500
|
-
schema?: QuerySchema;
|
|
1701
|
+
declare const getMigrationsSchemaAndTable: (adapter: AdapterBase, config: {
|
|
1501
1702
|
migrationsTable: string;
|
|
1502
1703
|
}) => {
|
|
1503
1704
|
schema?: string;
|
|
@@ -1518,7 +1719,6 @@ type DbParam = OrmParam | AdapterBase;
|
|
|
1518
1719
|
|
|
1519
1720
|
declare const saveMigratedVersion: (db: SilentQueries, version: string, name: string, config: Pick<RakeDbConfig, 'migrationsTable'>) => Promise<void>;
|
|
1520
1721
|
declare const createMigrationsSchemaAndTable: (db: DbParam, config: {
|
|
1521
|
-
schema?: QuerySchema;
|
|
1522
1722
|
migrationsTable: string;
|
|
1523
1723
|
logger?: QueryLogger;
|
|
1524
1724
|
}) => Promise<void>;
|
|
@@ -1541,7 +1741,8 @@ interface MigrateFn {
|
|
|
1541
1741
|
*/
|
|
1542
1742
|
declare const migrate: MigrateFn;
|
|
1543
1743
|
declare const migrateAndClose: MigrateFn;
|
|
1544
|
-
declare
|
|
1744
|
+
declare function runMigration(db: DbParam, migration: () => MaybePromise<unknown>): Promise<void>;
|
|
1745
|
+
declare function runMigration(db: DbParam, config: Pick<RakeDbConfig, 'transactionSearchPath'>, migration: () => MaybePromise<unknown>): Promise<void>;
|
|
1545
1746
|
/**
|
|
1546
1747
|
* Will roll back one latest applied migration,
|
|
1547
1748
|
* will apply `change` functions bottom-to-top.
|
|
@@ -1556,170 +1757,6 @@ declare const rollback: MigrateFn;
|
|
|
1556
1757
|
*/
|
|
1557
1758
|
declare const redo: MigrateFn;
|
|
1558
1759
|
|
|
1559
|
-
declare namespace DbStructure {
|
|
1560
|
-
interface TableNameAndSchemaName {
|
|
1561
|
-
schemaName: string;
|
|
1562
|
-
tableName: string;
|
|
1563
|
-
}
|
|
1564
|
-
interface Table {
|
|
1565
|
-
schemaName: string;
|
|
1566
|
-
name: string;
|
|
1567
|
-
comment?: string;
|
|
1568
|
-
columns: Column[];
|
|
1569
|
-
}
|
|
1570
|
-
interface View {
|
|
1571
|
-
schemaName: string;
|
|
1572
|
-
name: string;
|
|
1573
|
-
deps: RakeDbAst.View['deps'];
|
|
1574
|
-
isRecursive: boolean;
|
|
1575
|
-
with?: string[];
|
|
1576
|
-
columns: Column[];
|
|
1577
|
-
sql: string;
|
|
1578
|
-
}
|
|
1579
|
-
interface Procedure {
|
|
1580
|
-
schemaName: string;
|
|
1581
|
-
name: string;
|
|
1582
|
-
returnSet: boolean;
|
|
1583
|
-
returnType: string;
|
|
1584
|
-
kind: string;
|
|
1585
|
-
isTrigger: boolean;
|
|
1586
|
-
types: string[];
|
|
1587
|
-
argTypes: string[];
|
|
1588
|
-
argModes: ('i' | 'o')[];
|
|
1589
|
-
argNames?: string[];
|
|
1590
|
-
}
|
|
1591
|
-
interface Column extends TableNameAndSchemaName {
|
|
1592
|
-
name: string;
|
|
1593
|
-
typeSchema: string;
|
|
1594
|
-
type: string;
|
|
1595
|
-
arrayDims: number;
|
|
1596
|
-
maxChars?: number;
|
|
1597
|
-
numericPrecision?: number;
|
|
1598
|
-
numericScale?: number;
|
|
1599
|
-
dateTimePrecision?: number;
|
|
1600
|
-
default?: string;
|
|
1601
|
-
isNullable: boolean;
|
|
1602
|
-
collate?: string;
|
|
1603
|
-
compression?: 'pglz' | 'lz4';
|
|
1604
|
-
comment?: string;
|
|
1605
|
-
identity?: {
|
|
1606
|
-
always: boolean;
|
|
1607
|
-
start: number;
|
|
1608
|
-
increment: number;
|
|
1609
|
-
min?: number;
|
|
1610
|
-
max?: number;
|
|
1611
|
-
cache: number;
|
|
1612
|
-
cycle: boolean;
|
|
1613
|
-
};
|
|
1614
|
-
extension?: string;
|
|
1615
|
-
typmod: number;
|
|
1616
|
-
}
|
|
1617
|
-
interface Index extends TableNameAndSchemaName {
|
|
1618
|
-
name: string;
|
|
1619
|
-
using: string;
|
|
1620
|
-
unique: boolean;
|
|
1621
|
-
columns: (({
|
|
1622
|
-
column: string;
|
|
1623
|
-
} | {
|
|
1624
|
-
expression: string;
|
|
1625
|
-
}) & {
|
|
1626
|
-
collate?: string;
|
|
1627
|
-
opclass?: string;
|
|
1628
|
-
order?: string;
|
|
1629
|
-
weight?: SearchWeight;
|
|
1630
|
-
})[];
|
|
1631
|
-
include?: string[];
|
|
1632
|
-
nullsNotDistinct?: boolean;
|
|
1633
|
-
with?: string;
|
|
1634
|
-
tablespace?: string;
|
|
1635
|
-
where?: string;
|
|
1636
|
-
tsVector?: boolean;
|
|
1637
|
-
language?: string;
|
|
1638
|
-
languageColumn?: string;
|
|
1639
|
-
}
|
|
1640
|
-
interface Exclude extends Index {
|
|
1641
|
-
exclude: string[];
|
|
1642
|
-
}
|
|
1643
|
-
type ForeignKeyMatch = 'f' | 'p' | 's';
|
|
1644
|
-
type ForeignKeyAction = 'a' | 'r' | 'c' | 'n' | 'd';
|
|
1645
|
-
interface Constraint extends TableNameAndSchemaName {
|
|
1646
|
-
name: string;
|
|
1647
|
-
primaryKey?: string[];
|
|
1648
|
-
references?: References;
|
|
1649
|
-
check?: Check;
|
|
1650
|
-
}
|
|
1651
|
-
interface References {
|
|
1652
|
-
foreignSchema: string;
|
|
1653
|
-
foreignTable: string;
|
|
1654
|
-
columns: string[];
|
|
1655
|
-
foreignColumns: string[];
|
|
1656
|
-
match: ForeignKeyMatch;
|
|
1657
|
-
onUpdate: ForeignKeyAction;
|
|
1658
|
-
onDelete: ForeignKeyAction;
|
|
1659
|
-
}
|
|
1660
|
-
interface Check {
|
|
1661
|
-
columns?: string[];
|
|
1662
|
-
expression: string;
|
|
1663
|
-
}
|
|
1664
|
-
interface Trigger extends TableNameAndSchemaName {
|
|
1665
|
-
triggerSchema: string;
|
|
1666
|
-
name: string;
|
|
1667
|
-
events: string[];
|
|
1668
|
-
activation: string;
|
|
1669
|
-
condition?: string;
|
|
1670
|
-
definition: string;
|
|
1671
|
-
}
|
|
1672
|
-
interface Extension {
|
|
1673
|
-
schemaName: string;
|
|
1674
|
-
name: string;
|
|
1675
|
-
version?: string;
|
|
1676
|
-
}
|
|
1677
|
-
interface Enum {
|
|
1678
|
-
schemaName: string;
|
|
1679
|
-
name: string;
|
|
1680
|
-
values: [string, ...string[]];
|
|
1681
|
-
}
|
|
1682
|
-
interface Domain {
|
|
1683
|
-
schemaName: string;
|
|
1684
|
-
name: string;
|
|
1685
|
-
type: string;
|
|
1686
|
-
typeSchema: string;
|
|
1687
|
-
arrayDims: number;
|
|
1688
|
-
isNullable: boolean;
|
|
1689
|
-
maxChars?: number;
|
|
1690
|
-
numericPrecision?: number;
|
|
1691
|
-
numericScale?: number;
|
|
1692
|
-
dateTimePrecision?: number;
|
|
1693
|
-
collate?: string;
|
|
1694
|
-
default?: string;
|
|
1695
|
-
checks?: string[];
|
|
1696
|
-
}
|
|
1697
|
-
interface Collation {
|
|
1698
|
-
schemaName: string;
|
|
1699
|
-
name: string;
|
|
1700
|
-
provider: string;
|
|
1701
|
-
deterministic: boolean;
|
|
1702
|
-
lcCollate?: string;
|
|
1703
|
-
lcCType?: string;
|
|
1704
|
-
locale?: string;
|
|
1705
|
-
version?: string;
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1708
|
-
interface IntrospectedStructure {
|
|
1709
|
-
schemas: string[];
|
|
1710
|
-
tables: DbStructure.Table[];
|
|
1711
|
-
views: DbStructure.View[];
|
|
1712
|
-
indexes: DbStructure.Index[];
|
|
1713
|
-
excludes: DbStructure.Exclude[];
|
|
1714
|
-
constraints: DbStructure.Constraint[];
|
|
1715
|
-
triggers: DbStructure.Trigger[];
|
|
1716
|
-
extensions: DbStructure.Extension[];
|
|
1717
|
-
enums: DbStructure.Enum[];
|
|
1718
|
-
domains: DbStructure.Domain[];
|
|
1719
|
-
collations: DbStructure.Collation[];
|
|
1720
|
-
}
|
|
1721
|
-
declare function introspectDbSchema(db: AdapterBase): Promise<IntrospectedStructure>;
|
|
1722
|
-
|
|
1723
1760
|
declare const astToMigration: (currentSchema: string, config: RakeDbConfig, asts: RakeDbAst[]) => string | undefined;
|
|
1724
1761
|
|
|
1725
1762
|
interface StructureToAstCtx {
|
|
@@ -1734,9 +1771,10 @@ interface StructureToAstTableData {
|
|
|
1734
1771
|
indexes: DbStructure.Index[];
|
|
1735
1772
|
excludes: DbStructure.Exclude[];
|
|
1736
1773
|
constraints: DbStructure.Constraint[];
|
|
1774
|
+
roles?: DbStructure.Role[];
|
|
1737
1775
|
}
|
|
1738
1776
|
declare const makeStructureToAstCtx: (config: Pick<RakeDbConfig, 'snakeCase' | 'schemaConfig'>, currentSchema: string) => StructureToAstCtx;
|
|
1739
|
-
declare const structureToAst: (ctx: StructureToAstCtx, adapter: AdapterBase, config: Pick<RakeDbConfig, '
|
|
1777
|
+
declare const structureToAst: (ctx: StructureToAstCtx, adapter: AdapterBase, config: Pick<RakeDbConfig, 'migrationsTable'>) => Promise<RakeDbAst[]>;
|
|
1740
1778
|
declare const makeDomainsMap: (ctx: StructureToAstCtx, data: IntrospectedStructure) => DbStructureDomainsMap;
|
|
1741
1779
|
declare const instantiateDbColumn: (ctx: StructureToAstCtx, data: IntrospectedStructure, domains: DbStructureDomainsMap, dbColumn: DbStructure.Column) => Column<pqb.ColumnTypeSchemaArg, unknown, any, any, unknown, unknown, any, unknown, any>;
|
|
1742
1780
|
declare const tableToAst: (ctx: StructureToAstCtx, data: IntrospectedStructure, table: DbStructure.Table, action: 'create' | 'drop', domains: DbStructureDomainsMap) => RakeDbAst.Table;
|