mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 04:00:59 +00:00
delete columns
This commit is contained in:
parent
8ce4c0a7ce
commit
836d15c68f
@ -504,7 +504,7 @@ describe('Deploy database', () => {
|
||||
test.each(engines.filter(engine => engine.supportRenameSqlObject).map(engine => [engine.label, engine]))(
|
||||
'Mark view removed - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
await testDatabaseDeploy(engine, conn, driver, [[T1, V1], [T1]], {
|
||||
await testDatabaseDeploy(engine, conn, driver, [[T1, V1], [T1], [T1]], {
|
||||
markDeleted: true,
|
||||
disallowExtraObjects: true,
|
||||
finalCheckAgainstModel: [T1, V1_DELETED],
|
||||
@ -555,4 +555,14 @@ describe('Deploy database', () => {
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
test.each(engines.map(engine => [engine.label, engine]))(
|
||||
'Undelete column - %s',
|
||||
testWrapper(async (conn, driver, engine) => {
|
||||
await testDatabaseDeploy(engine, conn, driver, [[T1], [T1_NO_VAL], [T1]], {
|
||||
markDeleted: true,
|
||||
disallowExtraObjects: true,
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
|
@ -482,13 +482,24 @@ function planAlterTable(plan: AlterPlan, oldTable: TableInfo, newTable: TableInf
|
||||
columnPairs
|
||||
.filter(x => x[0] && x[1])
|
||||
.forEach(x => {
|
||||
if (!testEqualColumns(x[0], x[1], true, true, opts)) {
|
||||
if (testEqualColumns(x[0], x[1], false, true, opts) && !opts.noRenameColumn) {
|
||||
let srccol: ColumnInfo = x[0];
|
||||
let dstcol: ColumnInfo = x[1];
|
||||
if (hasDeletedPrefix(srccol.columnName, opts, opts.deletedColumnPrefix)) {
|
||||
plan.renameColumn(srccol, dstcol.columnName);
|
||||
// rename is already done
|
||||
srccol = {
|
||||
...srccol,
|
||||
columnName: dstcol.columnName,
|
||||
};
|
||||
}
|
||||
|
||||
if (!testEqualColumns(srccol, dstcol, true, true, opts)) {
|
||||
if (testEqualColumns(srccol, dstcol, false, true, opts) && !opts.noRenameColumn) {
|
||||
// console.log('PLAN RENAME COLUMN')
|
||||
plan.renameColumn(x[0], x[1].columnName);
|
||||
plan.renameColumn(srccol, dstcol.columnName);
|
||||
} else {
|
||||
// console.log('PLAN CHANGE COLUMN', x[0], x[1]);
|
||||
plan.changeColumn(x[0], x[1]);
|
||||
plan.changeColumn(srccol, dstcol);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -724,7 +735,9 @@ export function matchPairedObjects(db1: DatabaseInfo, db2: DatabaseInfo, opts: D
|
||||
|
||||
if (objectTypeField == 'tables') {
|
||||
for (const col2 of obj2.columns) {
|
||||
const col1 = obj1.columns.find(x => testEqualNames(x.columnName, col2.columnName, opts));
|
||||
const col1 = obj1.columns.find(x =>
|
||||
testEqualNames(x.columnName, col2.columnName, opts, opts.deletedColumnPrefix)
|
||||
);
|
||||
if (col1) col2.pairingId = col1.pairingId;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user