mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-02 18:23:59 +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)));
|
// 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));
|
return stableStringify(_omit(a, omitList)) == stableStringify(_omit(b, omitList));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,6 +334,8 @@ function planAlterTable(plan: AlterPlan, oldTable: TableInfo, newTable: TableInf
|
|||||||
getTableConstraints(newTable),
|
getTableConstraints(newTable),
|
||||||
(a, b) => a.constraintType == 'primaryKey' && b.constraintType == 'primaryKey'
|
(a, b) => a.constraintType == 'primaryKey' && b.constraintType == 'primaryKey'
|
||||||
);
|
);
|
||||||
|
// console.log('constraintPairs SOURCE', getTableConstraints(oldTable), getTableConstraints(newTable));
|
||||||
|
// console.log('constraintPairs', constraintPairs);
|
||||||
|
|
||||||
if (!opts.noDropConstraint) {
|
if (!opts.noDropConstraint) {
|
||||||
constraintPairs.filter(x => x[1] == null).forEach(x => plan.dropConstraint(x[0]));
|
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;
|
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 });
|
$: sourceDbValue = useDatabaseInfo({ conid: $values?.sourceConid, database: $values?.sourceDatabase });
|
||||||
$: targetDbValue = useDatabaseInfo({ conid: $values?.targetConid, database: $values?.targetDatabase });
|
$: targetDbValue = useDatabaseInfo({ conid: $values?.targetConid, database: $values?.targetDatabase });
|
||||||
|
|
||||||
$: console.log('$sourceDbValue', $sourceDbValue);
|
// $: console.log('$sourceDbValue', $sourceDbValue);
|
||||||
$: console.log('$targetDbValue', $targetDbValue);
|
// $: console.log('$targetDbValue', $targetDbValue);
|
||||||
|
|
||||||
$: sourceDb = generateDbPairingId($sourceDbValue);
|
$: sourceDb = generateDbPairingId($sourceDbValue);
|
||||||
$: targetDb = generateDbPairingId($targetDbValue);
|
$: targetDb = generateDbPairingId($targetDbValue);
|
||||||
@@ -184,18 +184,18 @@
|
|||||||
$: connection = useConnectionInfo({ conid: $values?.targetConid });
|
$: connection = useConnectionInfo({ conid: $values?.targetConid });
|
||||||
$: driver = findEngineDriver($connection, $extensions);
|
$: driver = findEngineDriver($connection, $extensions);
|
||||||
|
|
||||||
$: console.log('sourceDb', sourceDb);
|
// $: console.log('sourceDb', sourceDb);
|
||||||
$: console.log('targetDb', targetDb);
|
// $: console.log('targetDb', targetDb);
|
||||||
$: console.log('$connection', $connection);
|
// $: console.log('$connection', $connection);
|
||||||
$: console.log('$extensions', $extensions);
|
// $: console.log('$extensions', $extensions);
|
||||||
$: console.log('driver', driver);
|
// $: console.log('driver', driver);
|
||||||
|
|
||||||
$: targetDbPaired = matchPairedObjects(sourceDb, targetDb, dbDiffOptions);
|
$: targetDbPaired = matchPairedObjects(sourceDb, targetDb, dbDiffOptions);
|
||||||
$: diffRowsAll = _.sortBy(computeDbDiffRows(sourceDb, targetDbPaired, dbDiffOptions, driver), x =>
|
$: diffRowsAll = _.sortBy(computeDbDiffRows(sourceDb, targetDbPaired, dbDiffOptions, driver), x =>
|
||||||
stateOrder(x.state)
|
stateOrder(x.state)
|
||||||
);
|
);
|
||||||
|
|
||||||
$: console.log('diffRowsAll', diffRowsAll);
|
// $: console.log('diffRowsAll', diffRowsAll);
|
||||||
|
|
||||||
$: diffRows = filterDiffRows(diffRowsAll, $values, filter);
|
$: diffRows = filterDiffRows(diffRowsAll, $values, filter);
|
||||||
$: diffColumns = computeTableDiffColumns(
|
$: diffColumns = computeTableDiffColumns(
|
||||||
|
|||||||
Reference in New Issue
Block a user