mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 15:03:57 +00:00
fixed mssql primary key respects column order
This commit is contained in:
@@ -624,7 +624,9 @@ export function testEqualTables(
|
||||
) {
|
||||
const plan = new AlterPlan(wholeOldDb, wholeNewDb, driver.dialect, opts);
|
||||
planAlterTable(plan, a, b, opts);
|
||||
// console.log('plan.operations', a, b, plan.operations);
|
||||
// if (plan.operations.length > 0) {
|
||||
// console.log('************** plan.operations', a, b, plan.operations);
|
||||
// }
|
||||
return plan.operations.length == 0;
|
||||
}
|
||||
|
||||
@@ -856,7 +858,6 @@ export function matchPairedObjects(db1: DatabaseInfo, db2: DatabaseInfo, opts: D
|
||||
|
||||
export const modelCompareDbDiffOptions: DbDiffOptions = {
|
||||
ignoreCase: true,
|
||||
schemaMode: 'ignore',
|
||||
ignoreConstraintNames: true,
|
||||
ignoreForeignKeyActions: true,
|
||||
ignoreDataTypes: true,
|
||||
|
||||
@@ -145,6 +145,10 @@ export function isCollectionInfo(obj: { objectTypeField?: string }): obj is Coll
|
||||
}
|
||||
|
||||
export function filterStructureBySchema(db: DatabaseInfo, schema: string) {
|
||||
if (!db) {
|
||||
return db;
|
||||
}
|
||||
|
||||
return {
|
||||
...db,
|
||||
tables: (db.tables || []).filter(x => x.schemaName == schema),
|
||||
@@ -158,6 +162,10 @@ export function filterStructureBySchema(db: DatabaseInfo, schema: string) {
|
||||
}
|
||||
|
||||
export function getSchemasUsedByStructure(db: DatabaseInfo) {
|
||||
if (!db) {
|
||||
return db;
|
||||
}
|
||||
|
||||
return _uniq([
|
||||
...(db.tables || []).map(x => x.schemaName),
|
||||
...(db.views || []).map(x => x.schemaName),
|
||||
@@ -168,3 +176,30 @@ export function getSchemasUsedByStructure(db: DatabaseInfo) {
|
||||
...(db.triggers || []).map(x => x.schemaName),
|
||||
]);
|
||||
}
|
||||
|
||||
export function replaceSchemaInStructure(db: DatabaseInfo, schema: string) {
|
||||
if (!db) {
|
||||
return db;
|
||||
}
|
||||
|
||||
return {
|
||||
...db,
|
||||
tables: (db.tables || []).map(tbl => ({
|
||||
...tbl,
|
||||
schemaName: schema,
|
||||
columns: (tbl.columns || []).map(column => ({ ...column, schemaName: schema })),
|
||||
primaryKey: tbl.primaryKey ? { ...tbl.primaryKey, schemaName: schema } : undefined,
|
||||
sortingKey: tbl.sortingKey ? { ...tbl.sortingKey, schemaName: schema } : undefined,
|
||||
foreignKeys: (tbl.foreignKeys || []).map(fk => ({ ...fk, refSchemaName: schema, schemaName: schema })),
|
||||
indexes: (tbl.indexes || []).map(idx => ({ ...idx, schemaName: schema })),
|
||||
uniques: (tbl.uniques || []).map(idx => ({ ...idx, schemaName: schema })),
|
||||
checks: (tbl.checks || []).map(idx => ({ ...idx, schemaName: schema })),
|
||||
})),
|
||||
views: (db.views || []).map(x => ({ ...x, schemaName: schema })),
|
||||
collections: (db.collections || []).map(x => ({ ...x, schemaName: schema })),
|
||||
matviews: (db.matviews || []).map(x => ({ ...x, schemaName: schema })),
|
||||
procedures: (db.procedures || []).map(x => ({ ...x, schemaName: schema })),
|
||||
functions: (db.functions || []).map(x => ({ ...x, schemaName: schema })),
|
||||
triggers: (db.triggers || []).map(x => ({ ...x, schemaName: schema })),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user