feat: add changeColumn, renameColumn, dropColumn to firebird dumper

This commit is contained in:
Pavel
2025-05-22 16:49:29 +02:00
parent 8ea7d3d5e8
commit 808f7504c3

View File

@@ -4,6 +4,41 @@ class Dumper extends SqlDumper {
autoIncrement() {
this.put(' ^generated ^by ^default ^as ^identity');
}
dropColumn(column) {
this.putCmd('^alter ^table %f ^drop %i', column, column.columnName);
}
renameColumn(column, newName) {
this.putCmd('^alter ^table %f ^alter ^column %i ^to %i', column, column.columnName, newName);
}
changeColumn(oldcol, newcol, constraints) {
if (oldcol.columnName != newcol.columnName) {
this.putCmd('^alter ^table %f ^alter ^column %i ^to %i', oldcol, oldcol.columnName, 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) {
this.putCmd(
'^alter ^table %f ^alter ^column %i ^set ^default %s',
newcol,
newcol.columnName,
newcol.defaultValue
);
} else {
this.putCmd('^alter ^table %f ^alter ^column %i ^drop ^default', newcol, newcol.columnName);
}
}
}
}
module.exports = Dumper;