mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 04:26:01 +00:00
drop column with default works
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user