mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-29 16:53:58 +00:00
mdb diff: matching indexes
This commit is contained in:
@@ -274,6 +274,11 @@ function testEqualConstraints(a: ConstraintInfo, b: ConstraintInfo, opts: DbDiff
|
||||
// console.log('FK2', stableStringify(_omit(b, omitList)));
|
||||
// }
|
||||
|
||||
// if (a.constraintType == 'index' && b.constraintType == 'index') {
|
||||
// console.log('IX1', stableStringify(_omit(a, omitList)));
|
||||
// console.log('IX2', stableStringify(_omit(b, omitList)));
|
||||
// }
|
||||
|
||||
return stableStringify(_omit(a, omitList)) == stableStringify(_omit(b, omitList));
|
||||
}
|
||||
|
||||
@@ -329,6 +334,8 @@ function planAlterTable(plan: AlterPlan, oldTable: TableInfo, newTable: TableInf
|
||||
getTableConstraints(newTable),
|
||||
(a, b) => a.constraintType == 'primaryKey' && b.constraintType == 'primaryKey'
|
||||
);
|
||||
// console.log('constraintPairs SOURCE', getTableConstraints(oldTable), getTableConstraints(newTable));
|
||||
// console.log('constraintPairs', constraintPairs);
|
||||
|
||||
if (!opts.noDropConstraint) {
|
||||
constraintPairs.filter(x => x[1] == null).forEach(x => plan.dropConstraint(x[0]));
|
||||
@@ -526,6 +533,21 @@ export function matchPairedObjects(db1: DatabaseInfo, db2: DatabaseInfo, opts: D
|
||||
);
|
||||
if (fk1) fk2.pairingId = fk1.pairingId;
|
||||
}
|
||||
|
||||
for (const uq2 of obj2.uniques) {
|
||||
const uq1 = obj1.uniques.find(x =>
|
||||
_isEqual(
|
||||
x.columns.map(y => _pick(y, ['columnName'])),
|
||||
uq2.columns.map(y => _pick(y, ['columnName']))
|
||||
)
|
||||
);
|
||||
if (uq1) uq2.pairingId = uq1.pairingId;
|
||||
}
|
||||
|
||||
for (const ix2 of obj2.indexes) {
|
||||
const ix1 = obj1.indexes.find(x => testEqualNames(x.constraintName, ix2.constraintName, opts));
|
||||
if (ix1) ix2.pairingId = ix1.pairingId;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,8 +175,8 @@
|
||||
$: sourceDbValue = useDatabaseInfo({ conid: $values?.sourceConid, database: $values?.sourceDatabase });
|
||||
$: targetDbValue = useDatabaseInfo({ conid: $values?.targetConid, database: $values?.targetDatabase });
|
||||
|
||||
$: console.log('$sourceDbValue', $sourceDbValue);
|
||||
$: console.log('$targetDbValue', $targetDbValue);
|
||||
// $: console.log('$sourceDbValue', $sourceDbValue);
|
||||
// $: console.log('$targetDbValue', $targetDbValue);
|
||||
|
||||
$: sourceDb = generateDbPairingId($sourceDbValue);
|
||||
$: targetDb = generateDbPairingId($targetDbValue);
|
||||
@@ -184,18 +184,18 @@
|
||||
$: connection = useConnectionInfo({ conid: $values?.targetConid });
|
||||
$: driver = findEngineDriver($connection, $extensions);
|
||||
|
||||
$: console.log('sourceDb', sourceDb);
|
||||
$: console.log('targetDb', targetDb);
|
||||
$: console.log('$connection', $connection);
|
||||
$: console.log('$extensions', $extensions);
|
||||
$: console.log('driver', driver);
|
||||
// $: console.log('sourceDb', sourceDb);
|
||||
// $: console.log('targetDb', targetDb);
|
||||
// $: console.log('$connection', $connection);
|
||||
// $: console.log('$extensions', $extensions);
|
||||
// $: console.log('driver', driver);
|
||||
|
||||
$: targetDbPaired = matchPairedObjects(sourceDb, targetDb, dbDiffOptions);
|
||||
$: diffRowsAll = _.sortBy(computeDbDiffRows(sourceDb, targetDbPaired, dbDiffOptions, driver), x =>
|
||||
stateOrder(x.state)
|
||||
);
|
||||
|
||||
$: console.log('diffRowsAll', diffRowsAll);
|
||||
// $: console.log('diffRowsAll', diffRowsAll);
|
||||
|
||||
$: diffRows = filterDiffRows(diffRowsAll, $values, filter);
|
||||
$: diffColumns = computeTableDiffColumns(
|
||||
|
||||
Reference in New Issue
Block a user