mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 23:45:59 +00:00
alter table - change column dependencies
This commit is contained in:
@@ -62,6 +62,7 @@ const TESTED_COLUMNS = ['col_pk', 'col_std', 'col_def', 'col_fk', 'col_ref', 'co
|
||||
// const TESTED_COLUMNS = ['col_idx'];
|
||||
// const TESTED_COLUMNS = ['col_def'];
|
||||
// const TESTED_COLUMNS = ['col_std'];
|
||||
// const TESTED_COLUMNS = ['col_ref'];
|
||||
|
||||
function engines_columns_source() {
|
||||
return _.flatten(engines.map(engine => TESTED_COLUMNS.map(column => [engine.label, column, engine])));
|
||||
|
||||
@@ -222,6 +222,30 @@ export class AlterPlan {
|
||||
];
|
||||
return res;
|
||||
}
|
||||
|
||||
if (op.operationType == 'changeColumn') {
|
||||
const constraints = this._getDependendColumnConstraints(op.oldObject, this.dialect.changeColumnDependencies);
|
||||
|
||||
const res: AlterOperation[] = [
|
||||
...constraints.map(oldObject => {
|
||||
const opRes: AlterOperation = {
|
||||
operationType: 'dropConstraint',
|
||||
oldObject,
|
||||
};
|
||||
return opRes;
|
||||
}),
|
||||
op,
|
||||
..._.reverse([...constraints]).map(newObject => {
|
||||
const opRes: AlterOperation = {
|
||||
operationType: 'createConstraint',
|
||||
newObject,
|
||||
};
|
||||
return opRes;
|
||||
}),
|
||||
];
|
||||
return res;
|
||||
}
|
||||
|
||||
return [op];
|
||||
});
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ const dialect = {
|
||||
explicitDropConstraint: false,
|
||||
enableConstraintsPerTable: true,
|
||||
dropColumnDependencies: ['default', 'dependencies', 'indexes', 'primaryKey', 'foreignKeys', 'uniques'],
|
||||
changeColumnDependencies: ['indexes'],
|
||||
changeColumnDependencies: ['indexes', 'dependencies', 'uniques'],
|
||||
anonymousPrimaryKey: false,
|
||||
dropIndexContainsTableSpec: true,
|
||||
quoteIdentifier(s) {
|
||||
|
||||
Reference in New Issue
Block a user