mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
drop column with default works
This commit is contained in:
parent
e79e19c614
commit
eaa5970a0f
@ -60,7 +60,7 @@ async function testTableDiff(conn, driver, mangle) {
|
||||
// const TESTED_COLUMNS = ['col_pk', 'col_std', 'col_def', 'col_fk', 'col_ref', 'col_idx', 'col_uq'];
|
||||
// const TESTED_COLUMNS = ['col_pk'];
|
||||
// const TESTED_COLUMNS = ['col_idx'];
|
||||
const TESTED_COLUMNS = ['col_ref'];
|
||||
const TESTED_COLUMNS = ['col_def'];
|
||||
// const TESTED_COLUMNS = ['col_std'];
|
||||
|
||||
function engines_columns_source() {
|
||||
|
@ -117,10 +117,10 @@ const engines = [
|
||||
const filterLocal = [
|
||||
// filter local testing
|
||||
'-MySQL',
|
||||
'PostgreSQL',
|
||||
'-SQL Server',
|
||||
'-PostgreSQL',
|
||||
'SQL Server',
|
||||
'-SQLite',
|
||||
'CockroachDB',
|
||||
'-CockroachDB',
|
||||
];
|
||||
|
||||
module.exports = process.env.CITEST
|
||||
|
@ -32,6 +32,8 @@ function getColumnInfo({
|
||||
charMaxLength,
|
||||
numericPrecision,
|
||||
numericScale,
|
||||
defaultValue,
|
||||
defaultConstraint,
|
||||
}) {
|
||||
let fullDataType = dataType;
|
||||
if (charMaxLength && isTypeString(dataType)) fullDataType = `${dataType}(${charMaxLength})`;
|
||||
@ -42,6 +44,8 @@ function getColumnInfo({
|
||||
dataType: fullDataType,
|
||||
notNull: !isNullable,
|
||||
autoIncrement: !!isIdentity,
|
||||
defaultValue,
|
||||
defaultConstraint,
|
||||
};
|
||||
}
|
||||
|
||||
@ -99,21 +103,21 @@ class MsSqlAnalyser extends DatabaseAnalyser {
|
||||
.filter(idx => idx.object_id == row.objectId && !idx.is_unique_constraint)
|
||||
.map(idx => ({
|
||||
..._.pick(idx, ['constraintName', 'indexType', 'isUnique']),
|
||||
columns: indexcolsRows.rows.filter(
|
||||
col => col.object_id == idx.object_id && col.index_id == idx.index_id
|
||||
).map(col => ({
|
||||
..._.pick(col, ['columnName', 'isDescending', 'isIncludedColumn']),
|
||||
})),
|
||||
columns: indexcolsRows.rows
|
||||
.filter(col => col.object_id == idx.object_id && col.index_id == idx.index_id)
|
||||
.map(col => ({
|
||||
..._.pick(col, ['columnName', 'isDescending', 'isIncludedColumn']),
|
||||
})),
|
||||
})),
|
||||
uniques: indexesRows.rows
|
||||
.filter(idx => idx.object_id == row.objectId && idx.is_unique_constraint)
|
||||
.map(idx => ({
|
||||
..._.pick(idx, ['constraintName']),
|
||||
columns: indexcolsRows.rows.filter(
|
||||
col => col.object_id == idx.object_id && col.index_id == idx.index_id
|
||||
).map(col => ({
|
||||
..._.pick(col, ['columnName']),
|
||||
})),
|
||||
columns: indexcolsRows.rows
|
||||
.filter(col => col.object_id == idx.object_id && col.index_id == idx.index_id)
|
||||
.map(col => ({
|
||||
..._.pick(col, ['columnName']),
|
||||
})),
|
||||
})),
|
||||
}));
|
||||
|
||||
|
@ -65,6 +65,13 @@ class MsSqlDumper extends SqlDumper {
|
||||
super.dropTable(obj, options);
|
||||
}
|
||||
|
||||
dropColumn(column) {
|
||||
if (column.defaultConstraint) {
|
||||
this.putCmd('^alter ^table %f ^drop ^constraint %i', column, column.defaultConstraint);
|
||||
}
|
||||
super.dropColumn(column);
|
||||
}
|
||||
|
||||
dropDefault(col) {
|
||||
if (col.defaultConstraint) {
|
||||
this.putCmd('^alter ^table %f ^drop ^constraint %i', col, col.defaultConstraint);
|
||||
|
Loading…
Reference in New Issue
Block a user