#557 - DDL - DB Migration refactor - remove drop.ddl and use pendingDrops.

This commit is contained in:
Robin Bygrave
2016-02-11 20:26:53 +13:00
parent 1bee6fcae5
commit 6b490ed8b1
7 changed files with 9 additions and 51 deletions
@@ -179,8 +179,4 @@ public class DdlWrite {
return rollback;
}
public DdlBuffer drop() {
return apply;
}
}
@@ -544,7 +544,7 @@ public class BaseTableDdl implements TableDdl {
@Override
public void generate(DdlWrite writer, DropTable dropTable) throws IOException {
dropTable(writer.drop(), dropTable.getName());
dropTable(writer.apply(), dropTable.getName());
}
/**
@@ -555,14 +555,14 @@ public class BaseTableDdl implements TableDdl {
String tableName = dropColumn.getTableName();
alterTableDropColumn(writer.drop(), tableName, dropColumn.getColumnName());
alterTableDropColumn(writer.apply(), tableName, dropColumn.getColumnName());
if (isTrue(dropColumn.isWithHistory())) {
// also drop from the history table
regenerateHistoryTriggers(tableName, HistoryTableUpdate.Change.DROP, dropColumn.getColumnName());
alterTableDropColumn(writer.drop(), historyTable(tableName), dropColumn.getColumnName());
alterTableDropColumn(writer.apply(), historyTable(tableName), dropColumn.getColumnName());
}
writer.drop().end();
writer.apply().end();
}
/**
-37
View File
@@ -1,37 +0,0 @@
/**
* Created by rob on 11/02/16.
*/
public class FooTest {//
interface Colour {
int RED = 1;
}
static class SuperTest {
int RED = 999;
}
static class Test extends SuperTest implements Colour {
String RED = "RED";
public static void main(String[] args) {
new Test().printV();
}
void printV() {
System.out.println(super.RED + " " + this.RED + " " + RED + " " + Colour.RED);
}
}
// static class Test3 {
// public static void main(String[] args) {
// new Test().printV();
// }
//
// void printV2() {
// System.out.println(Colour.order);
// }
//
// }
}
@@ -46,7 +46,7 @@ public class BaseDdlHandlerTest extends BaseTestCase {
handler.generate(write, Helper.getDropColumn());
assertThat(write.drop().getBuffer()).isEqualTo("alter table foo drop column col2;\n\n");
assertThat(write.apply().getBuffer()).isEqualTo("alter table foo drop column col2;\n\n");
assertThat(write.rollback().getBuffer()).isEqualTo("");
}
@@ -77,7 +77,6 @@ public class BaseDdlHandlerTest extends BaseTestCase {
String rollbackLast = Helper.asText(this, "/assert/BaseDdlHandlerTest/rollback.sql");
assertThat(write.apply().getBuffer()).isEqualTo(apply);
assertThat(write.drop().getBuffer()).isEqualTo("alter table foo drop column col2;\n\n");
assertThat(write.rollback().getBuffer()).isEqualTo(rollbackLast);
}
@@ -35,8 +35,6 @@ public class H2HistoryDdlTest {
assertThat(write.applyHistory().isEmpty()).isFalse();
assertThat(write.applyHistory().getBuffer()).contains("add one");
assertThat(write.applyHistory().getBuffer()).doesNotContain("two");
assertThat(write.rollback().isEmpty()).isFalse();
}
@@ -64,7 +64,7 @@ public class HistoryTableUpdateTest {
upd.add(HistoryTableUpdate.Change.ADD, "two");
upd.add(HistoryTableUpdate.Change.DROP, "four");
assertThat(upd.description()).isEqualTo("add two");
assertThat(upd.description()).isEqualTo("[add two, drop four]");
}
@Test
@@ -76,7 +76,7 @@ public class HistoryTableUpdateTest {
upd.add(HistoryTableUpdate.Change.EXCLUDE, "six");
upd.add(HistoryTableUpdate.Change.DROP, "four");
assertThat(upd.description()).isEqualTo("add two, include five, exclude six");
assertThat(upd.description()).isEqualTo("[add two, include five, exclude six, drop four]");
}
List<String> current() {
@@ -9,3 +9,5 @@ create sequence foo_seq;
alter table foo add column added_to_foo varchar(20);
alter table foo drop column col2;