Merge pull request #1702 from FOCONIS/fix-mig-default-value

Fix: Migration when dbdefault is involved
This commit is contained in:
Rob Bygrave
2019-05-16 20:00:34 +12:00
committed by GitHub
37 changed files with 156 additions and 21 deletions
@@ -840,6 +840,7 @@ public class BaseTableDdl implements TableDdl {
/**
* This is mysql specific - alter all the base attributes of the column together.
* Will be called, if there is a type, dbdefault or notnull change.
*/
protected void alterColumnBaseAttributes(DdlWrite writer, AlterColumn alter) throws IOException {
@@ -30,10 +30,7 @@ public class HanaTableDdl extends BaseTableDdl {
@Override
protected void alterColumnDefaultValue(DdlWrite writer, AlterColumn alter) throws IOException {
String ddl = platformDdl.alterColumnBaseAttributes(alter);
if (hasValue(ddl)) {
writer.apply().append(ddl).endOfStatement();
}
// done in alterColumnBaseAttributes
}
@Override
@@ -112,7 +112,10 @@ public class MySqlDdl extends PlatformDdl {
@Override
public String alterColumnBaseAttributes(AlterColumn alter) {
if (DdlHelp.isDropDefault(alter.getDefaultValue())) {
if (alter.getType() == null
&& alter.isNotnull() == null) {
// No type change or notNull change
// defaultValue change already handled in alterColumnDefaultValue
return null;
}
String tableName = alter.getTableName();
@@ -149,7 +149,10 @@ public class SqlServerDdl extends PlatformDdl {
@Override
public String alterColumnBaseAttributes(AlterColumn alter) {
if (DdlHelp.isDropDefault(alter.getDefaultValue())) {
if (alter.getType() == null
&& alter.isNotnull() == null) {
// No type change or notNull change
// defaultValue change already handled in alterColumnDefaultValue
return null;
}
String tableName = alter.getTableName();