mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 22:36:01 +00:00
Update foreign key references when dropping or renaming columns in alter table tests
This commit is contained in:
@@ -182,7 +182,15 @@ describe('Alter table', () => {
|
|||||||
)(
|
)(
|
||||||
'Drop column - %s - %s',
|
'Drop column - %s - %s',
|
||||||
testWrapper(async (conn, driver, column, engine) => {
|
testWrapper(async (conn, driver, column, engine) => {
|
||||||
await testTableDiff(engine, conn, driver, tbl => (tbl.columns = tbl.columns.filter(x => x.columnName != column)));
|
await testTableDiff(engine, conn, driver,
|
||||||
|
tbl => {
|
||||||
|
tbl.columns = tbl.columns.filter(x => x.columnName != column);
|
||||||
|
tbl.foreignKeys = tbl.foreignKeys.map(fk => ({
|
||||||
|
...fk,
|
||||||
|
columns: fk.columns.filter(col => col.columnName != column)
|
||||||
|
})).filter(fk => fk.columns.length > 0);
|
||||||
|
}
|
||||||
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -205,7 +213,11 @@ describe('Alter table', () => {
|
|||||||
engine,
|
engine,
|
||||||
conn,
|
conn,
|
||||||
driver,
|
driver,
|
||||||
tbl => (tbl.columns = tbl.columns.map(x => (x.columnName == column ? { ...x, columnName: 'col_renamed' } : x)))
|
tbl => {
|
||||||
|
tbl.columns = tbl.columns.map(x => (x.columnName == column ? { ...x, columnName: 'col_renamed' } : x));
|
||||||
|
tbl.foreignKeys = tbl.foreignKeys.map(fk => ({...fk, columns: fk.columns.map(col => col.columnName == column ? { ...col, columnName: 'col_renamed' } : col)
|
||||||
|
}));
|
||||||
|
}
|
||||||
);
|
);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user