mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-03 08:13:57 +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_idx'];
|
||||||
// const TESTED_COLUMNS = ['col_def'];
|
// const TESTED_COLUMNS = ['col_def'];
|
||||||
// const TESTED_COLUMNS = ['col_std'];
|
// const TESTED_COLUMNS = ['col_std'];
|
||||||
|
// const TESTED_COLUMNS = ['col_ref'];
|
||||||
|
|
||||||
function engines_columns_source() {
|
function engines_columns_source() {
|
||||||
return _.flatten(engines.map(engine => TESTED_COLUMNS.map(column => [engine.label, column, engine])));
|
return _.flatten(engines.map(engine => TESTED_COLUMNS.map(column => [engine.label, column, engine])));
|
||||||
|
|||||||
@@ -222,6 +222,30 @@ export class AlterPlan {
|
|||||||
];
|
];
|
||||||
return res;
|
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];
|
return [op];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const dialect = {
|
|||||||
explicitDropConstraint: false,
|
explicitDropConstraint: false,
|
||||||
enableConstraintsPerTable: true,
|
enableConstraintsPerTable: true,
|
||||||
dropColumnDependencies: ['default', 'dependencies', 'indexes', 'primaryKey', 'foreignKeys', 'uniques'],
|
dropColumnDependencies: ['default', 'dependencies', 'indexes', 'primaryKey', 'foreignKeys', 'uniques'],
|
||||||
changeColumnDependencies: ['indexes'],
|
changeColumnDependencies: ['indexes', 'dependencies', 'uniques'],
|
||||||
anonymousPrimaryKey: false,
|
anonymousPrimaryKey: false,
|
||||||
dropIndexContainsTableSpec: true,
|
dropIndexContainsTableSpec: true,
|
||||||
quoteIdentifier(s) {
|
quoteIdentifier(s) {
|
||||||
|
|||||||
Reference in New Issue
Block a user