@mikro-orm/knex 6.4.6-dev.9 → 7.0.0-dev.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/AbstractSqlConnection.d.ts +15 -25
- package/AbstractSqlConnection.js +98 -126
- package/AbstractSqlDriver.d.ts +20 -13
- package/AbstractSqlDriver.js +73 -54
- package/AbstractSqlPlatform.d.ts +15 -3
- package/AbstractSqlPlatform.js +32 -11
- package/README.md +0 -2
- package/SqlEntityManager.d.ts +5 -6
- package/SqlEntityManager.js +5 -5
- package/SqlEntityRepository.d.ts +1 -6
- package/SqlEntityRepository.js +0 -6
- package/dialects/mssql/MsSqlNativeQueryBuilder.d.ts +12 -0
- package/dialects/mssql/MsSqlNativeQueryBuilder.js +161 -0
- package/dialects/mssql/index.d.ts +1 -1
- package/dialects/mssql/index.js +1 -1
- package/dialects/mysql/MySqlExceptionConverter.js +1 -0
- package/dialects/mysql/MySqlNativeQueryBuilder.d.ts +7 -0
- package/dialects/mysql/MySqlNativeQueryBuilder.js +81 -0
- package/dialects/mysql/MySqlPlatform.d.ts +5 -1
- package/dialects/mysql/MySqlPlatform.js +9 -1
- package/dialects/mysql/MySqlSchemaHelper.d.ts +6 -12
- package/dialects/mysql/MySqlSchemaHelper.js +42 -75
- package/dialects/mysql/index.d.ts +1 -3
- package/dialects/mysql/index.js +1 -3
- package/dialects/postgresql/PostgreSqlNativeQueryBuilder.d.ts +5 -0
- package/dialects/postgresql/PostgreSqlNativeQueryBuilder.js +12 -0
- package/dialects/postgresql/index.d.ts +1 -1
- package/dialects/postgresql/index.js +1 -1
- package/dialects/sqlite/BaseSqliteConnection.d.ts +0 -5
- package/dialects/sqlite/BaseSqliteConnection.js +4 -42
- package/dialects/sqlite/BaseSqlitePlatform.d.ts +15 -3
- package/dialects/sqlite/BaseSqlitePlatform.js +20 -4
- package/dialects/sqlite/SqliteExceptionConverter.d.ts +9 -0
- package/dialects/sqlite/SqliteExceptionConverter.js +55 -0
- package/dialects/sqlite/SqliteNativeQueryBuilder.d.ts +6 -0
- package/dialects/sqlite/SqliteNativeQueryBuilder.js +15 -0
- package/dialects/sqlite/SqliteSchemaHelper.d.ts +38 -0
- package/dialects/sqlite/SqliteSchemaHelper.js +384 -0
- package/dialects/sqlite/index.d.ts +3 -5
- package/dialects/sqlite/index.js +3 -5
- package/index.d.ts +1 -2
- package/index.js +3 -5
- package/index.mjs +10 -13
- package/package.json +4 -18
- package/query/CriteriaNodeFactory.js +5 -5
- package/query/NativeQueryBuilder.d.ts +108 -0
- package/query/NativeQueryBuilder.js +429 -0
- package/query/ObjectCriteriaNode.js +3 -3
- package/query/QueryBuilder.d.ts +30 -34
- package/query/QueryBuilder.js +112 -123
- package/query/QueryBuilderHelper.d.ts +27 -23
- package/query/QueryBuilderHelper.js +174 -168
- package/query/ScalarCriteriaNode.js +4 -0
- package/query/index.d.ts +1 -0
- package/query/index.js +1 -0
- package/schema/DatabaseSchema.js +9 -6
- package/schema/DatabaseTable.d.ts +2 -1
- package/schema/DatabaseTable.js +9 -5
- package/schema/SchemaComparator.d.ts +1 -2
- package/schema/SchemaComparator.js +31 -18
- package/schema/SchemaHelper.d.ts +27 -33
- package/schema/SchemaHelper.js +294 -184
- package/schema/SqlSchemaGenerator.d.ts +3 -9
- package/schema/SqlSchemaGenerator.js +105 -229
- package/typings.d.ts +7 -17
- package/MonkeyPatchable.d.ts +0 -18
- package/MonkeyPatchable.js +0 -60
- package/dialects/mssql/MsSqlColumnCompiler.d.ts +0 -4
- package/dialects/mssql/MsSqlColumnCompiler.js +0 -10
- package/dialects/mssql/MsSqlKnexDialect.d.ts +0 -6
- package/dialects/mssql/MsSqlKnexDialect.js +0 -22
- package/dialects/mssql/MsSqlQueryCompiler.d.ts +0 -12
- package/dialects/mssql/MsSqlQueryCompiler.js +0 -94
- package/dialects/mssql/MsSqlTableCompiler.d.ts +0 -9
- package/dialects/mssql/MsSqlTableCompiler.js +0 -40
- package/dialects/mysql/MariaDbKnexDialect.d.ts +0 -6
- package/dialects/mysql/MariaDbKnexDialect.js +0 -16
- package/dialects/mysql/MySqlColumnCompiler.d.ts +0 -7
- package/dialects/mysql/MySqlColumnCompiler.js +0 -26
- package/dialects/mysql/MySqlConnection.d.ts +0 -8
- package/dialects/mysql/MySqlConnection.js +0 -43
- package/dialects/mysql/MySqlKnexDialect.d.ts +0 -5
- package/dialects/mysql/MySqlKnexDialect.js +0 -17
- package/dialects/mysql/MySqlQueryCompiler.d.ts +0 -5
- package/dialects/mysql/MySqlQueryCompiler.js +0 -23
- package/dialects/postgresql/PostgreSqlKnexDialect.d.ts +0 -7
- package/dialects/postgresql/PostgreSqlKnexDialect.js +0 -20
- package/dialects/postgresql/PostgreSqlQueryCompiler.d.ts +0 -4
- package/dialects/postgresql/PostgreSqlQueryCompiler.js +0 -13
- package/dialects/postgresql/PostgreSqlTableCompiler.d.ts +0 -11
- package/dialects/postgresql/PostgreSqlTableCompiler.js +0 -89
- package/dialects/sqlite/BaseSqliteSchemaHelper.d.ts +0 -28
- package/dialects/sqlite/BaseSqliteSchemaHelper.js +0 -200
- package/dialects/sqlite/BetterSqliteKnexDialect.d.ts +0 -5
- package/dialects/sqlite/BetterSqliteKnexDialect.js +0 -15
- package/dialects/sqlite/LibSqlKnexDialect.d.ts +0 -11
- package/dialects/sqlite/LibSqlKnexDialect.js +0 -85
- package/dialects/sqlite/SqliteKnexDialect.d.ts +0 -8
- package/dialects/sqlite/SqliteKnexDialect.js +0 -67
- package/dialects/sqlite/SqliteTableCompiler.d.ts +0 -6
- package/dialects/sqlite/SqliteTableCompiler.js +0 -71
|
@@ -20,6 +20,7 @@ export declare class DatabaseTable {
|
|
|
20
20
|
}>;
|
|
21
21
|
comment?: string;
|
|
22
22
|
constructor(platform: AbstractSqlPlatform, name: string, schema?: string | undefined);
|
|
23
|
+
getQuotedName(): string;
|
|
23
24
|
getColumns(): Column[];
|
|
24
25
|
getColumn(name: string): Column | undefined;
|
|
25
26
|
removeColumn(name: string): void;
|
|
@@ -37,7 +38,7 @@ export declare class DatabaseTable {
|
|
|
37
38
|
/**
|
|
38
39
|
* The shortest name is stripped of the default namespace. All other namespaced elements are returned as full-qualified names.
|
|
39
40
|
*/
|
|
40
|
-
getShortestName(): string;
|
|
41
|
+
getShortestName(skipDefaultSchema?: boolean): string;
|
|
41
42
|
getForeignKeys(): Dictionary<ForeignKey>;
|
|
42
43
|
hasColumn(columnName: string): boolean;
|
|
43
44
|
getIndex(indexName: string): IndexDef | undefined;
|
package/schema/DatabaseTable.js
CHANGED
|
@@ -23,6 +23,9 @@ class DatabaseTable {
|
|
|
23
23
|
platform: { enumerable: false, writable: true },
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
+
getQuotedName() {
|
|
27
|
+
return this.platform.quoteIdentifier(this.getShortestName());
|
|
28
|
+
}
|
|
26
29
|
getColumns() {
|
|
27
30
|
return Object.values(this.columns);
|
|
28
31
|
}
|
|
@@ -76,14 +79,14 @@ class DatabaseTable {
|
|
|
76
79
|
prop.length ??= mappedType.getDefaultLength(this.platform);
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
|
-
const primary = !meta.compositePK &&
|
|
82
|
+
const primary = !meta.compositePK && prop.fieldNames.length === 1 && !!prop.primary;
|
|
80
83
|
this.columns[field] = {
|
|
81
84
|
name: prop.fieldNames[idx],
|
|
82
85
|
type: prop.columnTypes[idx],
|
|
83
86
|
generated: prop.generated,
|
|
84
87
|
mappedType,
|
|
85
88
|
unsigned: prop.unsigned && this.platform.isNumericColumn(mappedType),
|
|
86
|
-
autoincrement: prop.autoincrement ?? primary,
|
|
89
|
+
autoincrement: prop.autoincrement ?? (primary && prop.kind === core_1.ReferenceKind.SCALAR && this.platform.isNumericColumn(mappedType)),
|
|
87
90
|
primary,
|
|
88
91
|
nullable: this.columns[field]?.nullable ?? !!prop.nullable,
|
|
89
92
|
nativeEnumName: prop.nativeEnumName,
|
|
@@ -109,7 +112,7 @@ class DatabaseTable {
|
|
|
109
112
|
this.foreignKeys[constraintName] = {
|
|
110
113
|
constraintName,
|
|
111
114
|
columnNames: prop.fieldNames,
|
|
112
|
-
localTableName: this.getShortestName(),
|
|
115
|
+
localTableName: this.getShortestName(false),
|
|
113
116
|
referencedColumnNames: prop.referencedColumnNames,
|
|
114
117
|
referencedTableName: schema ? `${schema}.${prop.referencedTableName}` : prop.referencedTableName,
|
|
115
118
|
};
|
|
@@ -510,8 +513,9 @@ class DatabaseTable {
|
|
|
510
513
|
/**
|
|
511
514
|
* The shortest name is stripped of the default namespace. All other namespaced elements are returned as full-qualified names.
|
|
512
515
|
*/
|
|
513
|
-
getShortestName() {
|
|
514
|
-
|
|
516
|
+
getShortestName(skipDefaultSchema = true) {
|
|
517
|
+
const defaultSchema = this.platform.getDefaultSchemaName();
|
|
518
|
+
if (!this.schema || this.name.startsWith(defaultSchema + '.') || (this.schema === defaultSchema && skipDefaultSchema)) {
|
|
515
519
|
return this.name;
|
|
516
520
|
}
|
|
517
521
|
return `${this.schema}.${this.name}`;
|
|
@@ -37,9 +37,8 @@ export declare class SchemaComparator {
|
|
|
37
37
|
diffForeignKey(key1: ForeignKey, key2: ForeignKey, tableDifferences: TableDifference): boolean;
|
|
38
38
|
/**
|
|
39
39
|
* Returns the difference between the columns
|
|
40
|
-
* If there are differences this method returns field2, otherwise the boolean false.
|
|
41
40
|
*/
|
|
42
|
-
diffColumn(fromColumn: Column, toColumn: Column, fromTable: DatabaseTable,
|
|
41
|
+
diffColumn(fromColumn: Column, toColumn: Column, fromTable: DatabaseTable, logging?: boolean): Set<string>;
|
|
43
42
|
diffEnumItems(items1?: string[], items2?: string[]): boolean;
|
|
44
43
|
diffComment(comment1?: string, comment2?: string): boolean;
|
|
45
44
|
/**
|
|
@@ -66,7 +66,7 @@ class SchemaComparator {
|
|
|
66
66
|
diff.removedNativeEnums.push(nativeEnum);
|
|
67
67
|
}
|
|
68
68
|
for (const table of toSchema.getTables()) {
|
|
69
|
-
const tableName = table.getShortestName();
|
|
69
|
+
const tableName = table.getShortestName(false);
|
|
70
70
|
if (!fromSchema.hasTable(tableName)) {
|
|
71
71
|
diff.newTables[tableName] = toSchema.getTable(tableName);
|
|
72
72
|
}
|
|
@@ -146,7 +146,6 @@ class SchemaComparator {
|
|
|
146
146
|
}
|
|
147
147
|
const fromTableColumns = fromTable.getColumns();
|
|
148
148
|
const toTableColumns = toTable.getColumns();
|
|
149
|
-
const tableName = (toTable.schema ? toTable.schema + '.' : '') + toTable.name;
|
|
150
149
|
// See if all the columns in "from" table exist in "to" table
|
|
151
150
|
for (const column of toTableColumns) {
|
|
152
151
|
if (fromTable.hasColumn(column.name)) {
|
|
@@ -166,7 +165,7 @@ class SchemaComparator {
|
|
|
166
165
|
continue;
|
|
167
166
|
}
|
|
168
167
|
// See if column has changed properties in "to" table.
|
|
169
|
-
const changedProperties = this.diffColumn(column, toTable.getColumn(column.name), fromTable,
|
|
168
|
+
const changedProperties = this.diffColumn(column, toTable.getColumn(column.name), fromTable, true);
|
|
170
169
|
if (changedProperties.size === 0) {
|
|
171
170
|
continue;
|
|
172
171
|
}
|
|
@@ -235,11 +234,16 @@ class SchemaComparator {
|
|
|
235
234
|
changes++;
|
|
236
235
|
continue;
|
|
237
236
|
}
|
|
238
|
-
// See if
|
|
237
|
+
// See if check has changed in "to" table
|
|
239
238
|
const toTableCheck = toTable.getCheck(check.name);
|
|
239
|
+
const toColumn = toTable.getColumn(check.columnName);
|
|
240
|
+
const fromColumn = fromTable.getColumn(check.columnName);
|
|
240
241
|
if (!this.diffExpression(check.expression, toTableCheck.expression)) {
|
|
241
242
|
continue;
|
|
242
243
|
}
|
|
244
|
+
if (fromColumn?.enumItems && toColumn?.enumItems && !this.diffEnumItems(fromColumn.enumItems, toColumn.enumItems)) {
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
243
247
|
this.log(`check constraint ${check.name} changed in table ${tableDifferences.name}`, { fromTableCheck: check, toTableCheck });
|
|
244
248
|
tableDifferences.changedChecks[check.name] = toTableCheck;
|
|
245
249
|
changes++;
|
|
@@ -385,9 +389,8 @@ class SchemaComparator {
|
|
|
385
389
|
}
|
|
386
390
|
/**
|
|
387
391
|
* Returns the difference between the columns
|
|
388
|
-
* If there are differences this method returns field2, otherwise the boolean false.
|
|
389
392
|
*/
|
|
390
|
-
diffColumn(fromColumn, toColumn, fromTable,
|
|
393
|
+
diffColumn(fromColumn, toColumn, fromTable, logging) {
|
|
391
394
|
const changedProperties = new Set();
|
|
392
395
|
const fromProp = this.mapColumnToProperty({ ...fromColumn, autoincrement: false });
|
|
393
396
|
const toProp = this.mapColumnToProperty({ ...toColumn, autoincrement: false });
|
|
@@ -395,7 +398,7 @@ class SchemaComparator {
|
|
|
395
398
|
const fromNativeEnum = fromTable.nativeEnums[fromColumnType] ?? Object.values(fromTable.nativeEnums).find(e => e.name === fromColumnType && e.schema !== '*');
|
|
396
399
|
let toColumnType = this.platform.normalizeColumnType(toColumn.mappedType.getColumnType(toProp, this.platform).toLowerCase(), toProp);
|
|
397
400
|
const log = (msg, params) => {
|
|
398
|
-
if (
|
|
401
|
+
if (logging) {
|
|
399
402
|
const copy = core_1.Utils.copy(params);
|
|
400
403
|
core_1.Utils.dropUndefinedProperties(copy);
|
|
401
404
|
this.log(msg, copy);
|
|
@@ -409,45 +412,45 @@ class SchemaComparator {
|
|
|
409
412
|
toColumnType = `${fromTable.schema}.${toColumnType}`;
|
|
410
413
|
}
|
|
411
414
|
if (fromColumnType !== toColumnType) {
|
|
412
|
-
log(`'type' changed for column ${
|
|
415
|
+
log(`'type' changed for column ${fromTable.name}.${fromColumn.name}`, { fromColumnType, toColumnType });
|
|
413
416
|
changedProperties.add('type');
|
|
414
417
|
}
|
|
415
418
|
}
|
|
416
419
|
if (fromColumn.nullable !== toColumn.nullable && !fromColumn.generated && !toColumn.generated) {
|
|
417
|
-
log(`'nullable' changed for column ${
|
|
420
|
+
log(`'nullable' changed for column ${fromTable.name}.${fromColumn.name}`, { fromColumn, toColumn });
|
|
418
421
|
changedProperties.add('nullable');
|
|
419
422
|
}
|
|
420
423
|
if (this.diffExpression(fromColumn.generated, toColumn.generated)) {
|
|
421
|
-
log(`'generated' changed for column ${
|
|
424
|
+
log(`'generated' changed for column ${fromTable.name}.${fromColumn.name}`, { fromColumn, toColumn });
|
|
422
425
|
changedProperties.add('generated');
|
|
423
426
|
}
|
|
424
427
|
if (!!fromColumn.autoincrement !== !!toColumn.autoincrement) {
|
|
425
|
-
log(`'autoincrement' changed for column ${
|
|
428
|
+
log(`'autoincrement' changed for column ${fromTable.name}.${fromColumn.name}`, { fromColumn, toColumn });
|
|
426
429
|
changedProperties.add('autoincrement');
|
|
427
430
|
}
|
|
428
431
|
if (fromColumn.unsigned !== toColumn.unsigned && this.platform.supportsUnsigned()) {
|
|
429
|
-
log(`'unsigned' changed for column ${
|
|
432
|
+
log(`'unsigned' changed for column ${fromTable.name}.${fromColumn.name}`, { fromColumn, toColumn });
|
|
430
433
|
changedProperties.add('unsigned');
|
|
431
434
|
}
|
|
432
435
|
if (!(fromColumn.ignoreSchemaChanges?.includes('default') ||
|
|
433
436
|
toColumn.ignoreSchemaChanges?.includes('default')) && !this.hasSameDefaultValue(fromColumn, toColumn)) {
|
|
434
|
-
log(`'default' changed for column ${
|
|
437
|
+
log(`'default' changed for column ${fromTable.name}.${fromColumn.name}`, { fromColumn, toColumn });
|
|
435
438
|
changedProperties.add('default');
|
|
436
439
|
}
|
|
437
440
|
if (this.diffComment(fromColumn.comment, toColumn.comment)) {
|
|
438
|
-
log(`'comment' changed for column ${
|
|
441
|
+
log(`'comment' changed for column ${fromTable.name}.${fromColumn.name}`, { fromColumn, toColumn });
|
|
439
442
|
changedProperties.add('comment');
|
|
440
443
|
}
|
|
441
444
|
if (!(fromColumn.mappedType instanceof core_1.ArrayType) &&
|
|
442
445
|
!(toColumn.mappedType instanceof core_1.ArrayType) &&
|
|
443
446
|
this.diffEnumItems(fromColumn.enumItems, toColumn.enumItems)) {
|
|
444
|
-
log(`'enumItems' changed for column ${
|
|
447
|
+
log(`'enumItems' changed for column ${fromTable.name}.${fromColumn.name}`, { fromColumn, toColumn });
|
|
445
448
|
changedProperties.add('enumItems');
|
|
446
449
|
}
|
|
447
450
|
if ((fromColumn.extra || '').toLowerCase() !== (toColumn.extra || '').toLowerCase() &&
|
|
448
451
|
!(fromColumn.ignoreSchemaChanges?.includes('extra') ||
|
|
449
452
|
toColumn.ignoreSchemaChanges?.includes('extra'))) {
|
|
450
|
-
log(`'extra' changed for column ${
|
|
453
|
+
log(`'extra' changed for column ${fromTable.name}.${fromColumn.name}`, { fromColumn, toColumn });
|
|
451
454
|
changedProperties.add('extra');
|
|
452
455
|
}
|
|
453
456
|
return changedProperties;
|
|
@@ -499,12 +502,22 @@ class SchemaComparator {
|
|
|
499
502
|
// index that has no constraints.
|
|
500
503
|
return true;
|
|
501
504
|
}
|
|
502
|
-
|
|
505
|
+
if (this.platform.supportsDeferredUniqueConstraints() && index1.deferMode !== index2.deferMode) {
|
|
506
|
+
return false;
|
|
507
|
+
}
|
|
508
|
+
return index1.primary === index2.primary && index1.unique === index2.unique;
|
|
503
509
|
}
|
|
504
510
|
diffExpression(expr1, expr2) {
|
|
505
511
|
// expressions like check constraints might be normalized by the driver,
|
|
506
512
|
// e.g. quotes might be added (https://github.com/mikro-orm/mikro-orm/issues/3827)
|
|
507
|
-
const simplify = (str) =>
|
|
513
|
+
const simplify = (str) => {
|
|
514
|
+
return str
|
|
515
|
+
?.replace(/_\w+'(.*?)'/g, '$1')
|
|
516
|
+
.replace(/in\s*\((.*?)\)/ig, '= any (array[$1])')
|
|
517
|
+
.replace(/['"`()]|::\w+| +/g, '')
|
|
518
|
+
.replace(/anyarray\[(.*)]/ig, '$1')
|
|
519
|
+
.toLowerCase();
|
|
520
|
+
};
|
|
508
521
|
return simplify(expr1) !== simplify(expr2);
|
|
509
522
|
}
|
|
510
523
|
parseJsonDefault(defaultValue) {
|
package/schema/SchemaHelper.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type Connection, type Dictionary } from '@mikro-orm/core';
|
|
2
|
-
import type { Knex } from 'knex';
|
|
3
2
|
import type { AbstractSqlConnection } from '../AbstractSqlConnection';
|
|
4
3
|
import type { AbstractSqlPlatform } from '../AbstractSqlPlatform';
|
|
5
4
|
import type { CheckDef, Column, ForeignKey, IndexDef, Table, TableDifference } from '../typings';
|
|
@@ -8,41 +7,37 @@ import type { DatabaseTable } from './DatabaseTable';
|
|
|
8
7
|
export declare abstract class SchemaHelper {
|
|
9
8
|
protected readonly platform: AbstractSqlPlatform;
|
|
10
9
|
constructor(platform: AbstractSqlPlatform);
|
|
11
|
-
getSchemaBeginning(
|
|
10
|
+
getSchemaBeginning(_charset: string, disableForeignKeys?: boolean): string;
|
|
12
11
|
disableForeignKeysSQL(): string;
|
|
13
12
|
enableForeignKeysSQL(): string;
|
|
14
13
|
getSchemaEnd(disableForeignKeys?: boolean): string;
|
|
15
|
-
finalizeTable(table:
|
|
14
|
+
finalizeTable(table: DatabaseTable, charset: string, collate?: string): string;
|
|
15
|
+
appendComments(table: DatabaseTable): string[];
|
|
16
16
|
supportsSchemaConstraints(): boolean;
|
|
17
17
|
getPrimaryKeys(connection: AbstractSqlConnection, indexes: IndexDef[] | undefined, tableName: string, schemaName?: string): Promise<string[]>;
|
|
18
18
|
inferLengthFromColumnType(type: string): number | undefined;
|
|
19
|
-
getForeignKeys(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<Dictionary>;
|
|
20
19
|
protected getTableKey(t: Table): string;
|
|
21
|
-
getEnumDefinitions(connection: AbstractSqlConnection, checks: CheckDef[], tableName: string, schemaName?: string): Promise<Dictionary<string[]>>;
|
|
22
20
|
getCreateNativeEnumSQL(name: string, values: unknown[], schema?: string): string;
|
|
23
21
|
getDropNativeEnumSQL(name: string, schema?: string): string;
|
|
24
22
|
getAlterNativeEnumSQL(name: string, schema?: string, value?: string, items?: string[], oldItems?: string[]): string;
|
|
25
|
-
loadInformationSchema(schema: DatabaseSchema, connection: AbstractSqlConnection, tables: Table[], schemas?: string[]): Promise<void>;
|
|
23
|
+
abstract loadInformationSchema(schema: DatabaseSchema, connection: AbstractSqlConnection, tables: Table[], schemas?: string[]): Promise<void>;
|
|
26
24
|
getListTablesSQL(schemaName?: string): string;
|
|
27
25
|
getRenameColumnSQL(tableName: string, oldColumnName: string, to: Column, schemaName?: string): string;
|
|
28
|
-
getCreateIndexSQL(tableName: string, index: IndexDef
|
|
26
|
+
getCreateIndexSQL(tableName: string, index: IndexDef): string;
|
|
29
27
|
getDropIndexSQL(tableName: string, index: IndexDef): string;
|
|
30
|
-
getRenameIndexSQL(tableName: string, index: IndexDef, oldIndexName: string): string;
|
|
28
|
+
getRenameIndexSQL(tableName: string, index: IndexDef, oldIndexName: string): string[];
|
|
29
|
+
alterTable(diff: TableDifference, safe?: boolean): string[];
|
|
30
|
+
getAddColumnsSQL(table: DatabaseTable, columns: Column[]): string[];
|
|
31
31
|
getDropColumnsSQL(tableName: string, columns: Column[], schemaName?: string): string;
|
|
32
32
|
hasNonDefaultPrimaryKeyName(table: DatabaseTable): boolean;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
getPreAlterTable(tableDiff: TableDifference, safe: boolean): string;
|
|
37
|
-
getPostAlterTable(tableDiff: TableDifference, safe: boolean): string;
|
|
38
|
-
getAlterColumnAutoincrement(tableName: string, column: Column, schemaName?: string): string;
|
|
33
|
+
castColumn(name: string, type: string): string;
|
|
34
|
+
alterTableColumn(column: Column, table: DatabaseTable, changedProperties: Set<string>): string[];
|
|
35
|
+
createTableColumn(column: Column, table: DatabaseTable, changedProperties?: Set<string>): string | undefined;
|
|
36
|
+
getPreAlterTable(tableDiff: TableDifference, safe: boolean): string[];
|
|
37
|
+
getPostAlterTable(tableDiff: TableDifference, safe: boolean): string[];
|
|
39
38
|
getChangeColumnCommentSQL(tableName: string, to: Column, schemaName?: string): string;
|
|
40
39
|
getNamespaces(connection: AbstractSqlConnection): Promise<string[]>;
|
|
41
|
-
getColumns(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<Column[]>;
|
|
42
|
-
getIndexes(connection: AbstractSqlConnection, tableName: string, schemaName?: string): Promise<IndexDef[]>;
|
|
43
|
-
getChecks(connection: AbstractSqlConnection, tableName: string, schemaName?: string, columns?: Column[]): Promise<CheckDef[]>;
|
|
44
40
|
protected mapIndexes(indexes: IndexDef[]): Promise<IndexDef[]>;
|
|
45
|
-
getForeignKeysSQL(tableName: string, schemaName?: string): string;
|
|
46
41
|
mapForeignKeys(fks: any[], tableName: string, schemaName?: string): Dictionary;
|
|
47
42
|
normalizeDefaultValue(defaultValue: string, length?: number, defaultValues?: Dictionary<string[]>): string | number;
|
|
48
43
|
getCreateDatabaseSQL(name: string): string;
|
|
@@ -54,27 +49,26 @@ export declare abstract class SchemaHelper {
|
|
|
54
49
|
getManagementDbName(): string;
|
|
55
50
|
getDefaultEmptyString(): string;
|
|
56
51
|
databaseExists(connection: Connection, name: string): Promise<boolean>;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
createTable(tableDef: DatabaseTable, alter?: boolean): Knex.SchemaBuilder;
|
|
63
|
-
createForeignKey(table: Knex.CreateTableBuilder, foreignKey: ForeignKey, schema?: string): void;
|
|
64
|
-
splitTableName(name: string): [string | undefined, string];
|
|
52
|
+
append(array: string[], sql: string | string[], pad?: boolean): void;
|
|
53
|
+
createTable(table: DatabaseTable, alter?: boolean): string[];
|
|
54
|
+
alterTableComment(table: DatabaseTable, comment?: string): string;
|
|
55
|
+
createForeignKey(table: DatabaseTable, foreignKey: ForeignKey, alterTable?: boolean, inline?: boolean): string;
|
|
56
|
+
splitTableName(name: string, skipDefaultSchema?: boolean): [string | undefined, string];
|
|
65
57
|
getReferencedTableName(referencedTableName: string, schema?: string): string;
|
|
66
|
-
createIndex(
|
|
67
|
-
createCheck(table:
|
|
68
|
-
|
|
58
|
+
createIndex(index: IndexDef, table: DatabaseTable, createPrimary?: boolean): string;
|
|
59
|
+
createCheck(table: DatabaseTable, check: CheckDef): string;
|
|
60
|
+
protected getTableName(table: string, schema?: string): string;
|
|
69
61
|
getTablesGroupedBySchemas(tables: Table[]): Map<string | undefined, Table[]>;
|
|
70
|
-
getAlterTable?(changedTable: TableDifference, wrap?: boolean): Promise<string>;
|
|
71
|
-
get knex(): Knex;
|
|
72
62
|
get options(): {
|
|
73
63
|
disableForeignKeys?: boolean;
|
|
74
64
|
createForeignKeyConstraints?: boolean;
|
|
75
65
|
ignoreSchema?: string[];
|
|
76
66
|
managementDbName?: string;
|
|
77
67
|
};
|
|
78
|
-
|
|
79
|
-
protected
|
|
68
|
+
protected processComment(comment: string): string;
|
|
69
|
+
protected quote(...keys: (string | undefined)[]): string;
|
|
70
|
+
dropForeignKey(tableName: string, constraintName: string): string;
|
|
71
|
+
dropIndex(table: string, index: IndexDef, oldIndexName?: string): string;
|
|
72
|
+
dropConstraint(table: string, name: string): string;
|
|
73
|
+
dropTableIfExists(name: string, schema?: string): string;
|
|
80
74
|
}
|