mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-30 18:34:01 +00:00
force recreate table when changing autoincrement flag
This commit is contained in:
@@ -166,4 +166,14 @@ describe('Alter table', () => {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
test.each(engines.map(engine => [engine.label, engine]))(
|
||||||
|
'Change autoincrement - %s',
|
||||||
|
testWrapper(async (conn, driver, engine) => {
|
||||||
|
await testTableDiff(engine, conn, driver, tbl => {
|
||||||
|
tbl.columns.find(x => x.columnName == 'col_pk').autoIncrement = true;
|
||||||
|
});
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -191,8 +191,8 @@ const filterLocal = [
|
|||||||
'-MySQL',
|
'-MySQL',
|
||||||
'-MariaDB',
|
'-MariaDB',
|
||||||
'-PostgreSQL',
|
'-PostgreSQL',
|
||||||
'-SQL Server',
|
'SQL Server',
|
||||||
'SQLite',
|
'-SQLite',
|
||||||
'-CockroachDB',
|
'-CockroachDB',
|
||||||
'-ClickHouse',
|
'-ClickHouse',
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -416,6 +416,12 @@ export class AlterPlan {
|
|||||||
this._testTableRecreate(op, 'createConstraint', obj => this._canCreateConstraint(obj), 'newObject') ||
|
this._testTableRecreate(op, 'createConstraint', obj => this._canCreateConstraint(obj), 'newObject') ||
|
||||||
this._testTableRecreate(op, 'dropConstraint', obj => this._canDropConstraint(obj), 'oldObject') ||
|
this._testTableRecreate(op, 'dropConstraint', obj => this._canDropConstraint(obj), 'oldObject') ||
|
||||||
this._testTableRecreate(op, 'changeColumn', this.dialect.changeColumn, 'newObject') ||
|
this._testTableRecreate(op, 'changeColumn', this.dialect.changeColumn, 'newObject') ||
|
||||||
|
this._testTableRecreate(
|
||||||
|
op,
|
||||||
|
'changeColumn',
|
||||||
|
obj => this._canChangeAutoIncrement(obj, op as AlterOperation_ChangeColumn),
|
||||||
|
'newObject'
|
||||||
|
) ||
|
||||||
this._testTableRecreate(op, 'renameColumn', true, 'object') || [op]
|
this._testTableRecreate(op, 'renameColumn', true, 'object') || [op]
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
@@ -443,6 +449,13 @@ export class AlterPlan {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_canChangeAutoIncrement(column: ColumnInfo, op: AlterOperation_ChangeColumn) {
|
||||||
|
if (!!column.autoIncrement != !!op.oldObject.autoIncrement) {
|
||||||
|
return this.dialect.changeAutoIncrement;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
_testTableRecreate(
|
_testTableRecreate(
|
||||||
op: AlterOperation,
|
op: AlterOperation,
|
||||||
operationType: string,
|
operationType: string,
|
||||||
|
|||||||
1
packages/types/dialect.d.ts
vendored
1
packages/types/dialect.d.ts
vendored
@@ -24,6 +24,7 @@ export interface SqlDialect {
|
|||||||
createColumn?: boolean;
|
createColumn?: boolean;
|
||||||
dropColumn?: boolean;
|
dropColumn?: boolean;
|
||||||
changeColumn?: boolean;
|
changeColumn?: boolean;
|
||||||
|
changeAutoIncrement?: boolean;
|
||||||
createIndex?: boolean;
|
createIndex?: boolean;
|
||||||
dropIndex?: boolean;
|
dropIndex?: boolean;
|
||||||
createForeignKey?: boolean;
|
createForeignKey?: boolean;
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ const dialect = {
|
|||||||
createColumn: true,
|
createColumn: true,
|
||||||
dropColumn: true,
|
dropColumn: true,
|
||||||
changeColumn: true,
|
changeColumn: true,
|
||||||
|
changeAutoIncrement: true,
|
||||||
createIndex: true,
|
createIndex: true,
|
||||||
dropIndex: true,
|
dropIndex: true,
|
||||||
anonymousPrimaryKey: true,
|
anonymousPrimaryKey: true,
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ const dialect = {
|
|||||||
createColumn: true,
|
createColumn: true,
|
||||||
dropColumn: true,
|
dropColumn: true,
|
||||||
changeColumn: true,
|
changeColumn: true,
|
||||||
|
changeAutoIncrement: true,
|
||||||
createIndex: true,
|
createIndex: true,
|
||||||
dropIndex: true,
|
dropIndex: true,
|
||||||
createForeignKey: true,
|
createForeignKey: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user