mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 09:44:00 +00:00
Merge branch 'master' into feature/mongo-server-summary
This commit is contained in:
@@ -13,10 +13,6 @@ module.exports = {
|
||||
return null;
|
||||
},
|
||||
|
||||
async loadSuperadminPermissions() {
|
||||
return [];
|
||||
},
|
||||
|
||||
getConnectionsForLoginPage_meta: true,
|
||||
async getConnectionsForLoginPage() {
|
||||
return null;
|
||||
|
||||
@@ -292,6 +292,16 @@ export class AlterPlan {
|
||||
}
|
||||
}
|
||||
|
||||
_hasOnlyCommentChange(op: AlterOperation): boolean {
|
||||
if (op.operationType === 'changeColumn') {
|
||||
return _.isEqual(
|
||||
_.omit(op.oldObject, ['columnComment', 'ordinal']),
|
||||
_.omit(op.newObject, ['columnComment', 'ordinal'])
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
_getDependendColumnConstraints(column: ColumnInfo, dependencyDefinition) {
|
||||
const table = this.wholeOldDb.tables.find(x => x.pureName == column.pureName && x.schemaName == column.schemaName);
|
||||
if (!table) return [];
|
||||
@@ -337,31 +347,42 @@ export class AlterPlan {
|
||||
]) {
|
||||
if (op.operationType == testedOperationType) {
|
||||
const constraints = this._getDependendColumnConstraints(testedObject as ColumnInfo, testedDependencies);
|
||||
const ignoreContraints = this.dialect.safeCommentChanges && this._hasOnlyCommentChange(op);
|
||||
|
||||
// if (constraints.length > 0 && this.opts.noDropConstraint) {
|
||||
// return [];
|
||||
// }
|
||||
|
||||
const res: AlterOperation[] = [
|
||||
...constraints.map(oldObject => {
|
||||
const opRes: AlterOperation = {
|
||||
operationType: 'dropConstraint',
|
||||
oldObject,
|
||||
isRecreate: true,
|
||||
};
|
||||
return opRes;
|
||||
}),
|
||||
op,
|
||||
..._.reverse([...constraints]).map(newObject => {
|
||||
const opRes: AlterOperation = {
|
||||
operationType: 'createConstraint',
|
||||
newObject,
|
||||
};
|
||||
return opRes;
|
||||
}),
|
||||
];
|
||||
const res: AlterOperation[] = [];
|
||||
|
||||
if (constraints.length > 0) {
|
||||
if (!ignoreContraints) {
|
||||
res.push(
|
||||
...constraints.map(oldObject => {
|
||||
const opRes: AlterOperation = {
|
||||
operationType: 'dropConstraint',
|
||||
oldObject,
|
||||
isRecreate: true,
|
||||
};
|
||||
return opRes;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
res.push(op);
|
||||
|
||||
if (!ignoreContraints) {
|
||||
res.push(
|
||||
..._.reverse([...constraints]).map(newObject => {
|
||||
const opRes: AlterOperation = {
|
||||
operationType: 'createConstraint',
|
||||
newObject,
|
||||
};
|
||||
return opRes;
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (!ignoreContraints && constraints.length > 0) {
|
||||
this.recreates.constraints += 1;
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -59,6 +59,7 @@ export interface DbDiffOptions {
|
||||
|
||||
ignoreForeignKeyActions?: boolean;
|
||||
ignoreDataTypes?: boolean;
|
||||
ignoreComments?: boolean;
|
||||
}
|
||||
|
||||
export function generateTablePairingId(table: TableInfo): TableInfo {
|
||||
@@ -322,11 +323,14 @@ export function testEqualColumns(
|
||||
);
|
||||
return false;
|
||||
}
|
||||
if ((a.columnComment || '') != (b.columnComment || '')) {
|
||||
console.debug(
|
||||
`Column ${a.pureName}.${a.columnName}, ${b.pureName}.${b.columnName}: different comment: ${a.columnComment}, ${b.columnComment}`
|
||||
);
|
||||
return false;
|
||||
|
||||
if (!opts.ignoreComments) {
|
||||
if ((a.columnComment || '') != (b.columnComment || '')) {
|
||||
console.debug(
|
||||
`Column ${a.pureName}.${a.columnName}, ${b.pureName}.${b.columnName}: different comment: ${a.columnComment}, ${b.columnComment}`
|
||||
);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!testEqualTypes(a, b, opts)) {
|
||||
|
||||
8
packages/types/dialect.d.ts
vendored
8
packages/types/dialect.d.ts
vendored
@@ -74,6 +74,14 @@ export interface SqlDialect {
|
||||
|
||||
predefinedDataTypes: string[];
|
||||
|
||||
columnProperties?: {
|
||||
columnName?: boolean;
|
||||
isSparse?: true;
|
||||
isPersisted?: true;
|
||||
};
|
||||
|
||||
safeCommentChanges?: boolean;
|
||||
|
||||
// create sql-tree expression
|
||||
createColumnViewExpression(
|
||||
columnName: string,
|
||||
|
||||
3
packages/types/test-engines.d.ts
vendored
3
packages/types/test-engines.d.ts
vendored
@@ -56,6 +56,9 @@ export type TestEngineInfo = {
|
||||
|
||||
useTextTypeForStrings?: boolean;
|
||||
|
||||
supportTableComments?: boolean;
|
||||
supportColumnComments?: boolean;
|
||||
|
||||
supportRenameSqlObject?: boolean;
|
||||
supportSchemas?: boolean;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user