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', 'col_std', 'col_def', 'col_fk', 'col_ref', 'col_idx', 'col_uq'];
|
||||||
// const TESTED_COLUMNS = ['col_pk'];
|
// const TESTED_COLUMNS = ['col_pk'];
|
||||||
// const TESTED_COLUMNS = ['col_idx'];
|
// const TESTED_COLUMNS = ['col_idx'];
|
||||||
const TESTED_COLUMNS = ['col_ref'];
|
const TESTED_COLUMNS = ['col_def'];
|
||||||
// const TESTED_COLUMNS = ['col_std'];
|
// const TESTED_COLUMNS = ['col_std'];
|
||||||
|
|
||||||
function engines_columns_source() {
|
function engines_columns_source() {
|
||||||
|
@ -117,10 +117,10 @@ const engines = [
|
|||||||
const filterLocal = [
|
const filterLocal = [
|
||||||
// filter local testing
|
// filter local testing
|
||||||
'-MySQL',
|
'-MySQL',
|
||||||
'PostgreSQL',
|
'-PostgreSQL',
|
||||||
'-SQL Server',
|
'SQL Server',
|
||||||
'-SQLite',
|
'-SQLite',
|
||||||
'CockroachDB',
|
'-CockroachDB',
|
||||||
];
|
];
|
||||||
|
|
||||||
module.exports = process.env.CITEST
|
module.exports = process.env.CITEST
|
||||||
|
@ -32,6 +32,8 @@ function getColumnInfo({
|
|||||||
charMaxLength,
|
charMaxLength,
|
||||||
numericPrecision,
|
numericPrecision,
|
||||||
numericScale,
|
numericScale,
|
||||||
|
defaultValue,
|
||||||
|
defaultConstraint,
|
||||||
}) {
|
}) {
|
||||||
let fullDataType = dataType;
|
let fullDataType = dataType;
|
||||||
if (charMaxLength && isTypeString(dataType)) fullDataType = `${dataType}(${charMaxLength})`;
|
if (charMaxLength && isTypeString(dataType)) fullDataType = `${dataType}(${charMaxLength})`;
|
||||||
@ -42,6 +44,8 @@ function getColumnInfo({
|
|||||||
dataType: fullDataType,
|
dataType: fullDataType,
|
||||||
notNull: !isNullable,
|
notNull: !isNullable,
|
||||||
autoIncrement: !!isIdentity,
|
autoIncrement: !!isIdentity,
|
||||||
|
defaultValue,
|
||||||
|
defaultConstraint,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,9 +103,9 @@ class MsSqlAnalyser extends DatabaseAnalyser {
|
|||||||
.filter(idx => idx.object_id == row.objectId && !idx.is_unique_constraint)
|
.filter(idx => idx.object_id == row.objectId && !idx.is_unique_constraint)
|
||||||
.map(idx => ({
|
.map(idx => ({
|
||||||
..._.pick(idx, ['constraintName', 'indexType', 'isUnique']),
|
..._.pick(idx, ['constraintName', 'indexType', 'isUnique']),
|
||||||
columns: indexcolsRows.rows.filter(
|
columns: indexcolsRows.rows
|
||||||
col => col.object_id == idx.object_id && col.index_id == idx.index_id
|
.filter(col => col.object_id == idx.object_id && col.index_id == idx.index_id)
|
||||||
).map(col => ({
|
.map(col => ({
|
||||||
..._.pick(col, ['columnName', 'isDescending', 'isIncludedColumn']),
|
..._.pick(col, ['columnName', 'isDescending', 'isIncludedColumn']),
|
||||||
})),
|
})),
|
||||||
})),
|
})),
|
||||||
@ -109,9 +113,9 @@ class MsSqlAnalyser extends DatabaseAnalyser {
|
|||||||
.filter(idx => idx.object_id == row.objectId && idx.is_unique_constraint)
|
.filter(idx => idx.object_id == row.objectId && idx.is_unique_constraint)
|
||||||
.map(idx => ({
|
.map(idx => ({
|
||||||
..._.pick(idx, ['constraintName']),
|
..._.pick(idx, ['constraintName']),
|
||||||
columns: indexcolsRows.rows.filter(
|
columns: indexcolsRows.rows
|
||||||
col => col.object_id == idx.object_id && col.index_id == idx.index_id
|
.filter(col => col.object_id == idx.object_id && col.index_id == idx.index_id)
|
||||||
).map(col => ({
|
.map(col => ({
|
||||||
..._.pick(col, ['columnName']),
|
..._.pick(col, ['columnName']),
|
||||||
})),
|
})),
|
||||||
})),
|
})),
|
||||||
|
@ -65,6 +65,13 @@ class MsSqlDumper extends SqlDumper {
|
|||||||
super.dropTable(obj, options);
|
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) {
|
dropDefault(col) {
|
||||||
if (col.defaultConstraint) {
|
if (col.defaultConstraint) {
|
||||||
this.putCmd('^alter ^table %f ^drop ^constraint %i', col, col.defaultConstraint);
|
this.putCmd('^alter ^table %f ^drop ^constraint %i', col, col.defaultConstraint);
|
||||||
|
Loading…
Reference in New Issue
Block a user