mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 04:26:01 +00:00
oracle alter table passes
This commit is contained in:
@@ -60,9 +60,9 @@ class Dumper extends SqlDumper {
|
||||
// this.putCmd('^alter ^table %f ^rename ^to %i', obj, newname);
|
||||
// }
|
||||
|
||||
// renameColumn(column, newcol) {
|
||||
// this.putCmd('^alter ^table %f ^rename ^column %i ^to %i', column, column.columnName, newcol);
|
||||
// }
|
||||
renameColumn(column, newcol) {
|
||||
this.putCmd('^alter ^table %f ^rename ^column %i ^to %i', column, column.columnName, newcol);
|
||||
}
|
||||
|
||||
// dropTable(obj, options = {}) {
|
||||
// this.put('^drop ^table');
|
||||
@@ -87,30 +87,46 @@ class Dumper extends SqlDumper {
|
||||
// super.columnDefinition(col, options);
|
||||
// }
|
||||
|
||||
// changeColumn(oldcol, newcol, constraints) {
|
||||
// if (oldcol.columnName != newcol.columnName) {
|
||||
// this.putCmd('^alter ^table %f ^rename ^column %i ^to %i', oldcol, oldcol.columnName, newcol.columnName);
|
||||
// }
|
||||
// if (!testEqualTypes(oldcol, newcol)) {
|
||||
// this.putCmd('^alter ^table %f ^alter ^column %i ^type %s', oldcol, newcol.columnName, newcol.dataType);
|
||||
// }
|
||||
// if (oldcol.notNull != newcol.notNull) {
|
||||
// if (newcol.notNull) this.putCmd('^alter ^table %f ^alter ^column %i ^set ^not ^null', newcol, newcol.columnName);
|
||||
// else this.putCmd('^alter ^table %f ^alter ^column %i ^drop ^not ^null', newcol, newcol.columnName);
|
||||
// }
|
||||
// if (oldcol.defaultValue != newcol.defaultValue) {
|
||||
// if (newcol.defaultValue == null) {
|
||||
// this.putCmd('^alter ^table %f ^alter ^column %i ^drop ^default', newcol, newcol.columnName);
|
||||
// } else {
|
||||
// this.putCmd(
|
||||
// '^alter ^table %f ^alter ^column %i ^set ^default %s',
|
||||
// newcol,
|
||||
// newcol.columnName,
|
||||
// newcol.defaultValue
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
changeColumn(oldcol, newcol, constraints) {
|
||||
if (oldcol.columnName != newcol.columnName) {
|
||||
this.putCmd('^alter ^table %f ^rename ^column %i ^to %i', oldcol, oldcol.columnName, newcol.columnName);
|
||||
}
|
||||
|
||||
if (!testEqualTypes(oldcol, newcol) || oldcol.notNull != newcol.notNull) {
|
||||
this.putCmd(
|
||||
'^alter ^table %f ^modify (%i %s %k)',
|
||||
newcol,
|
||||
newcol.columnName,
|
||||
newcol.dataType,
|
||||
newcol.notNull ? 'not null' : 'null'
|
||||
);
|
||||
}
|
||||
|
||||
if (oldcol.defaultValue != newcol.defaultValue) {
|
||||
if (newcol.defaultValue?.trim()) {
|
||||
this.putCmd('^alter ^table %f ^modify (%i ^default %s)', newcol, newcol.columnName, newcol.defaultValue);
|
||||
} else {
|
||||
this.putCmd('^alter ^table %f ^modify (%i ^default ^null)', newcol, newcol.columnName);
|
||||
}
|
||||
}
|
||||
|
||||
// if (oldcol.notNull != newcol.notNull) {
|
||||
// if (newcol.notNull) this.putCmd('^alter ^table %f ^alter ^column %i ^set ^not ^null', newcol, newcol.columnName);
|
||||
// else this.putCmd('^alter ^table %f ^alter ^column %i ^drop ^not ^null', newcol, newcol.columnName);
|
||||
// }
|
||||
// if (oldcol.defaultValue != newcol.defaultValue) {
|
||||
// if (newcol.defaultValue == null) {
|
||||
// this.putCmd('^alter ^table %f ^alter ^column %i ^drop ^default', newcol, newcol.columnName);
|
||||
// } else {
|
||||
// this.putCmd(
|
||||
// '^alter ^table %f ^alter ^column %i ^set ^default %s',
|
||||
// newcol,
|
||||
// newcol.columnName,
|
||||
// newcol.defaultValue
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// putValue(value) {
|
||||
// if (value === true) this.putRaw('true');
|
||||
|
||||
Reference in New Issue
Block a user