diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/FlywayMigrator.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/FlywayMigrator.java index 47b23e83548..f9ed2c5ec12 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/FlywayMigrator.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/FlywayMigrator.java @@ -68,9 +68,6 @@ public class FlywayMigrator { } public void addTask(BaseTask theTask) { - if (theTask.getVersion() == null) { - theTask.setVersion("2." + (++ourVersion)); - } myTasks.add(new FlywayMigration(theTask, this)); } diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddForeignKeyTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddForeignKeyTask.java index a984c100087..ff77ae98fde 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddForeignKeyTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddForeignKeyTask.java @@ -37,6 +37,10 @@ public class AddForeignKeyTask extends BaseTableColumnTask { private String myForeignTableName; private String myForeignColumnName; + public AddForeignKeyTask(String theVersion) { + super(theVersion); + } + public void setConstraintName(String theConstraintName) { myConstraintName = theConstraintName; } diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIdGeneratorTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIdGeneratorTask.java index 5f522bc745d..bf532322046 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIdGeneratorTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIdGeneratorTask.java @@ -36,7 +36,8 @@ public class AddIdGeneratorTask extends BaseTask { private static final Logger ourLog = LoggerFactory.getLogger(AddIdGeneratorTask.class); private final String myGeneratorName; - public AddIdGeneratorTask(String theGeneratorName) { + public AddIdGeneratorTask(String theVersion, String theGeneratorName) { + super(theVersion); myGeneratorName = theGeneratorName; } diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIndexTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIndexTask.java index 5f687576910..655855012b2 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIndexTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddIndexTask.java @@ -39,6 +39,10 @@ public class AddIndexTask extends BaseTableTask { private List myColumns; private Boolean myUnique; + public AddIndexTask(String theVersion) { + super(theVersion); + } + public void setIndexName(String theIndexName) { myIndexName = StringUtils.toUpperCase(theIndexName, Locale.US); } diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddTableByColumnTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddTableByColumnTask.java index 911acc0b0e3..ed5d094f624 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddTableByColumnTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddTableByColumnTask.java @@ -36,6 +36,10 @@ public class AddTableByColumnTask extends BaseTableTask { private List myAddColumnTasks = new ArrayList<>(); private String myPkColumn; + public AddTableByColumnTask(String theVersion) { + super(theVersion); + } + public void addAddColumnTask(AddColumnTask theTask) { Validate.notNull(theTask); myAddColumnTasks.add(theTask); diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddTableRawSqlTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddTableRawSqlTask.java index 70d98d8e129..544346dae10 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddTableRawSqlTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/AddTableRawSqlTask.java @@ -37,6 +37,10 @@ public class AddTableRawSqlTask extends BaseTableTask { private Map> myDriverToSqls = new HashMap<>(); private List myDriverNeutralSqls = new ArrayList<>(); + public AddTableRawSqlTask(String theVersion) { + super(theVersion); + } + public void addSql(DriverTypeEnum theDriverType, @Language("SQL") String theSql) { Validate.notNull(theDriverType); Validate.notBlank(theSql); diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ArbitrarySqlTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ArbitrarySqlTask.java index de64bda2543..8342af0aa67 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ArbitrarySqlTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ArbitrarySqlTask.java @@ -44,7 +44,8 @@ public class ArbitrarySqlTask extends BaseTask { private String myExecuteOnlyIfTableExists; private List myConditionalOnExistenceOf = new ArrayList<>(); - public ArbitrarySqlTask(String theTableName, String theDescription) { + public ArbitrarySqlTask(String theVersion, String theTableName, String theDescription) { + super(theVersion); myTableName = theTableName; myDescription = theDescription; } diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTableColumnTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTableColumnTask.java index e17980c2615..784fbd4aa8d 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTableColumnTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTableColumnTask.java @@ -29,6 +29,10 @@ public abstract class BaseTableColumnTask extends BaseT private String myColumnName; + public BaseTableColumnTask(String theVersion) { + super(theVersion); + } + @SuppressWarnings("unchecked") public T setColumnName(String theColumnName) { myColumnName = StringUtils.toUpperCase(theColumnName, Locale.US); diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTableColumnTypeTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTableColumnTypeTask.java index d16d1f5aaef..0d58d58e696 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTableColumnTypeTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTableColumnTypeTask.java @@ -38,7 +38,9 @@ public abstract class BaseTableColumnTypeTask extends B /** * Constructor */ - BaseTableColumnTypeTask() { + + public BaseTableColumnTypeTask(String theVersion) { + super(theVersion); setColumnType(ColumnTypeEnum.INT, DriverTypeEnum.H2_EMBEDDED, "integer"); setColumnType(ColumnTypeEnum.INT, DriverTypeEnum.DERBY_EMBEDDED, "integer"); setColumnType(ColumnTypeEnum.INT, DriverTypeEnum.MARIADB_10_1, "integer"); diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTableTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTableTask.java index 65d2d417d1e..f20be95164a 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTableTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTableTask.java @@ -25,6 +25,10 @@ import org.apache.commons.lang3.Validate; public abstract class BaseTableTask extends BaseTask { private String myTableName; + public BaseTableTask(String theVersion) { + super(theVersion); + } + public String getTableName() { return myTableName; } diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java index ca6a00e7092..798b7e94252 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/BaseTask.java @@ -43,8 +43,11 @@ public abstract class BaseTask { private boolean myDryRun; private List myExecutedStatements = new ArrayList<>(); private boolean myNoColumnShrink; - // FIXME KHS final - private String version; + private final String version; + + protected BaseTask(String theVersion) { + version = theVersion; + } public boolean isNoColumnShrink() { return myNoColumnShrink; @@ -136,11 +139,6 @@ public abstract class BaseTask { return version; } - public BaseTask setVersion(String theVersion) { - version = theVersion; - return this; - } - public static class ExecutedStatement { private final String mySql; private final List myArguments; diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/CalculateHashesTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/CalculateHashesTask.java index 3ec85cb3dfa..cb4bb3b1fab 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/CalculateHashesTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/CalculateHashesTask.java @@ -53,8 +53,8 @@ public class CalculateHashesTask extends BaseTableColumnTask { private static final Logger ourLog = LoggerFactory.getLogger(DropColumnTask.class); + public DropColumnTask(String theVersion) { + super(theVersion); + } @Override public void execute() throws SQLException { diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropForeignKeyTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropForeignKeyTask.java index e74510e329f..0f320b12b8d 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropForeignKeyTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropForeignKeyTask.java @@ -40,6 +40,10 @@ public class DropForeignKeyTask extends BaseTableTask { private String myConstraintName; private String myParentTableName; + public DropForeignKeyTask(String theVersion) { + super(theVersion); + } + public void setConstraintName(String theConstraintName) { myConstraintName = theConstraintName; } diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropIdGeneratorTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropIdGeneratorTask.java index 6ef1960e0cc..d70503b8b72 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropIdGeneratorTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropIdGeneratorTask.java @@ -36,7 +36,8 @@ public class DropIdGeneratorTask extends BaseTask { private static final Logger ourLog = LoggerFactory.getLogger(DropIdGeneratorTask.class); private final String myGeneratorName; - public DropIdGeneratorTask(String theGeneratorName) { + public DropIdGeneratorTask(String theVersion, String theGeneratorName) { + super(theVersion); myGeneratorName = theGeneratorName; } diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropIndexTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropIndexTask.java index 93500b4565f..1e961873f23 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropIndexTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropIndexTask.java @@ -35,6 +35,10 @@ public class DropIndexTask extends BaseTableTask { private static final Logger ourLog = LoggerFactory.getLogger(DropIndexTask.class); private String myIndexName; + public DropIndexTask(String theVersion) { + super(theVersion); + } + @Override public void validate() { super.validate(); diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropTableTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropTableTask.java index 135c5544681..b99ef8c59a9 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropTableTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/DropTableTask.java @@ -33,6 +33,10 @@ public class DropTableTask extends BaseTableTask { private static final Logger ourLog = LoggerFactory.getLogger(DropTableTask.class); + public DropTableTask(String theVersion) { + super(theVersion); + } + @Override public void execute() throws SQLException { Set tableNames = JdbcUtils.getTableNames(getConnectionProperties()); diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ExecuteRawSqlTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ExecuteRawSqlTask.java index d091a1e492f..3a3fb1a82f4 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ExecuteRawSqlTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ExecuteRawSqlTask.java @@ -34,6 +34,10 @@ public class ExecuteRawSqlTask extends BaseTask { private Map> myDriverToSqls = new HashMap<>(); private List myDriverNeutralSqls = new ArrayList<>(); + public ExecuteRawSqlTask(String theVersion) { + super(theVersion); + } + public ExecuteRawSqlTask addSql(DriverTypeEnum theDriverType, @Language("SQL") String theSql) { Validate.notNull(theDriverType); Validate.notBlank(theSql); diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/LogStartSectionWithMessageTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/LogStartSectionWithMessageTask.java index 692942410e4..ec8a1f92b22 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/LogStartSectionWithMessageTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/LogStartSectionWithMessageTask.java @@ -28,7 +28,8 @@ public class LogStartSectionWithMessageTask extends BaseTask { private static final Logger ourLog = LoggerFactory.getLogger(LogStartSectionWithMessageTask.class); private final String myMessage; - public LogStartSectionWithMessageTask(String theMessage) { + public LogStartSectionWithMessageTask(String theVersion, String theMessage) { + super(theVersion); myMessage = theMessage; } diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ModifyColumnTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ModifyColumnTask.java index f0683fe496d..6e160a7cc35 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ModifyColumnTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/ModifyColumnTask.java @@ -32,6 +32,14 @@ public class ModifyColumnTask extends BaseTableColumnTypeTask private static final Logger ourLog = LoggerFactory.getLogger(ModifyColumnTask.class); + /** + * Constructor + * + * @param theVersion + */ + public ModifyColumnTask(String theVersion) { + super(theVersion); + } @Override public void execute() throws SQLException { diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/RenameColumnTask.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/RenameColumnTask.java index 596273c0ef0..854c19df4da 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/RenameColumnTask.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/taskdef/RenameColumnTask.java @@ -38,6 +38,10 @@ public class RenameColumnTask extends BaseTableTask { private boolean myAllowNeitherColumnToExist; private boolean myDeleteTargetColumnFirstIfBothExist; + public RenameColumnTask(String theVersion) { + super(theVersion); + } + public void setDeleteTargetColumnFirstIfBothExist(boolean theDeleteTargetColumnFirstIfBothExist) { myDeleteTargetColumnFirstIfBothExist = theDeleteTargetColumnFirstIfBothExist; } diff --git a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/api/BaseMigrationTasks.java b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/api/BaseMigrationTasks.java index 16d2b43f3b2..499904b8594 100644 --- a/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/api/BaseMigrationTasks.java +++ b/hapi-fhir-jpaserver-migrate/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/api/BaseMigrationTasks.java @@ -88,37 +88,37 @@ public class BaseMigrationTasks { mySink.addTask(theTask); } - public BuilderAddTableRawSql addTableRawSql(String theTableName) { - return new BuilderAddTableRawSql(theTableName); + public BuilderAddTableRawSql addTableRawSql(String theVersion, String theTableName) { + return new BuilderAddTableRawSql(theVersion, theTableName); } - public Builder executeRawSql(@Language("SQL") String theSql) { - mySink.addTask(new ExecuteRawSqlTask().addSql(theSql)); + public Builder executeRawSql(String theVersion, @Language("SQL") String theSql) { + mySink.addTask(new ExecuteRawSqlTask(theVersion).addSql(theSql)); return this; } - public Builder executeRawSql(DriverTypeEnum theDriver, @Language("SQL") String theSql) { - mySink.addTask(new ExecuteRawSqlTask().addSql(theDriver, theSql)); + public Builder executeRawSql(String theVersion, DriverTypeEnum theDriver, @Language("SQL") String theSql) { + mySink.addTask(new ExecuteRawSqlTask(theVersion).addSql(theDriver, theSql)); return this; } public Builder startSectionWithMessage(String theMessage) { Validate.notBlank(theMessage); - addTask(new LogStartSectionWithMessageTask(theMessage)); + addTask(new LogStartSectionWithMessageTask("log message", theMessage)); return this; } - public BuilderAddTableByColumns addTableByColumns(String theTableName, String thePkColumnName) { - return new BuilderAddTableByColumns(mySink, theTableName, thePkColumnName); + public BuilderAddTableByColumns addTableByColumns(String theVersion, String theTableName, String thePkColumnName) { + return new BuilderAddTableByColumns(theVersion, mySink, theTableName, thePkColumnName); } - public void addIdGenerator(String theGeneratorName) { - AddIdGeneratorTask task = new AddIdGeneratorTask(theGeneratorName); + public void addIdGenerator(String theVersion, String theGeneratorName) { + AddIdGeneratorTask task = new AddIdGeneratorTask(theVersion, theGeneratorName); addTask(task); } - public void dropIdGenerator(String theIdGeneratorName) { - DropIdGeneratorTask task = new DropIdGeneratorTask(theIdGeneratorName); + public void dropIdGenerator(String theVersion, String theIdGeneratorName) { + DropIdGeneratorTask task = new DropIdGeneratorTask(theVersion, theIdGeneratorName); addTask(task); } @@ -126,8 +126,8 @@ public class BaseMigrationTasks { private final AddTableRawSqlTask myTask; - protected BuilderAddTableRawSql(String theTableName) { - myTask = new AddTableRawSqlTask(); + protected BuilderAddTableRawSql(String theVersion, String theTableName) { + myTask = new AddTableRawSqlTask(theVersion); myTask.setTableName(theTableName); addTask(myTask); } @@ -146,9 +146,9 @@ public class BaseMigrationTasks { public class BuilderAddTableByColumns extends BuilderWithTableName implements IAcceptsTasks { private final AddTableByColumnTask myTask; - public BuilderAddTableByColumns(IAcceptsTasks theSink, String theTableName, String thePkColumnName) { + public BuilderAddTableByColumns(String theVersion, IAcceptsTasks theSink, String theTableName, String thePkColumnName) { super(theSink, theTableName); - myTask = new AddTableByColumnTask(); + myTask = new AddTableByColumnTask(theVersion); myTask.setTableName(theTableName); myTask.setPkColumn(thePkColumnName); theSink.addTask(myTask); @@ -182,15 +182,15 @@ public class BaseMigrationTasks { return myTableName; } - public void dropIndex(String theIndexName) { - DropIndexTask task = new DropIndexTask(); + public void dropIndex(String theVersion, String theIndexName) { + DropIndexTask task = new DropIndexTask(theVersion); task.setIndexName(theIndexName); task.setTableName(myTableName); addTask(task); } - public void dropThisTable() { - DropTableTask task = new DropTableTask(); + public void dropThisTable(String theVersion) { + DropTableTask task = new DropTableTask(theVersion); task.setTableName(myTableName); addTask(task); } @@ -203,9 +203,9 @@ public class BaseMigrationTasks { return new BuilderAddColumnWithName(theColumnName, this); } - public void dropColumn(String theColumnName) { + public void dropColumn(String theVersion, String theColumnName) { Validate.notBlank(theColumnName); - DropColumnTask task = new DropColumnTask(); + DropColumnTask task = new DropColumnTask(theVersion); task.setTableName(myTableName); task.setColumnName(theColumnName); addTask(task); @@ -225,8 +225,8 @@ public class BaseMigrationTasks { return new BuilderAddForeignKey(theForeignKeyName); } - public BuilderWithTableName renameColumn(String theOldName, String theNewName) { - return renameColumn(theOldName, theNewName, false, false); + public BuilderWithTableName renameColumn(String theVersion, String theOldName, String theNewName) { + return renameColumn(theVersion, theOldName, theNewName, false, false); } /** @@ -235,8 +235,8 @@ public class BaseMigrationTasks { * @param theAllowNeitherColumnToExist Setting this to true means that it's not an error if neither column exists * @param theDeleteTargetColumnFirstIfBothEixst Setting this to true causes the migrator to be ok with the target column existing. It will make sure that there is no data in the column with the new name, then delete it if so in order to make room for the renamed column. If there is data it will still bomb out. */ - public BuilderWithTableName renameColumn(String theOldName, String theNewName, boolean theAllowNeitherColumnToExist, boolean theDeleteTargetColumnFirstIfBothEixst) { - RenameColumnTask task = new RenameColumnTask(); + public BuilderWithTableName renameColumn(String theVersion, String theOldName, String theNewName, boolean theAllowNeitherColumnToExist, boolean theDeleteTargetColumnFirstIfBothEixst) { + RenameColumnTask task = new RenameColumnTask(theVersion); task.setTableName(myTableName); task.setOldName(theOldName); task.setNewName(theNewName); @@ -251,8 +251,8 @@ public class BaseMigrationTasks { * @param theFkName the name of the foreign key * @param theParentTableName the name of the table that exports the foreign key */ - public void dropForeignKey(String theFkName, String theParentTableName) { - DropForeignKeyTask task = new DropForeignKeyTask(); + public void dropForeignKey(String theVersion, String theFkName, String theParentTableName) { + DropForeignKeyTask task = new DropForeignKeyTask(theVersion); task.setConstraintName(theFkName); task.setTableName(getTableName()); task.setParentTableName(theParentTableName); @@ -277,8 +277,8 @@ public class BaseMigrationTasks { myUnique = theUnique; } - public void withColumns(String... theColumnNames) { - AddIndexTask task = new AddIndexTask(); + public void withColumns(String theVersion, String... theColumnNames) { + AddIndexTask task = new AddIndexTask(theVersion); task.setTableName(myTableName); task.setIndexName(myIndexName); task.setUnique(myUnique); @@ -316,11 +316,11 @@ public class BaseMigrationTasks { myNullable = theNullable; } - public void withType(BaseTableColumnTypeTask.ColumnTypeEnum theColumnType) { - withType(theColumnType, null); + public void withType(String theVersion, BaseTableColumnTypeTask.ColumnTypeEnum theColumnType) { + withType(theVersion, theColumnType, null); } - public void withType(BaseTableColumnTypeTask.ColumnTypeEnum theColumnType, Integer theLength) { + public void withType(String theVersion, BaseTableColumnTypeTask.ColumnTypeEnum theColumnType, Integer theLength) { if (theColumnType == BaseTableColumnTypeTask.ColumnTypeEnum.STRING) { if (theLength == null || theLength == 0) { throw new IllegalArgumentException("Can not specify length 0 for column of type " + theColumnType); @@ -331,7 +331,7 @@ public class BaseMigrationTasks { } } - ModifyColumnTask task = new ModifyColumnTask(); + ModifyColumnTask task = new ModifyColumnTask(theVersion); task.setColumnName(myColumnName); task.setTableName(myTableName); if (theLength != null) { @@ -360,8 +360,8 @@ public class BaseMigrationTasks { super(theColumnName); } - public void references(String theForeignTable, String theForeignColumn) { - AddForeignKeyTask task = new AddForeignKeyTask(); + public void references(String theVersion, String theForeignTable, String theForeignColumn) { + AddForeignKeyTask task = new AddForeignKeyTask(theVersion); task.setTableName(myTableName); task.setConstraintName(myForeignKeyName); task.setColumnName(getColumnName());