#1474 - IllegalStateException: Table [some_table] does not exists in model? ... when applying drop table migration and table is no longer in the model

This commit is contained in:
rob bygrave
2018-08-21 20:45:31 +12:00
parent f3d26e32ec
commit 663b1bb4aa
3 changed files with 41 additions and 19 deletions
@@ -1,6 +1,9 @@
package io.ebeaninternal.dbmigration.model;
import io.ebeaninternal.dbmigration.migration.DropHistoryTable;
import io.ebeaninternal.dbmigration.migration.DropIndex;
import io.ebeaninternal.dbmigration.migration.DropTable;
import io.ebeaninternal.dbmigration.migration.Migration;
import io.ebeaninternal.dbmigration.migrationreader.MigrationXmlReader;
import org.junit.Test;
@@ -79,6 +82,31 @@ public class ModelContainerTest {
assertThat(container.getPendingDrops()).isEmpty();
}
@Test
public void apply_dropTable_when_notInModel_then_ok() {
ModelContainer container = new ModelContainer();
container.apply(mig("5.0__dropTable.model.xml"), ver("5.0"));
assertThat(container.getTables()).isEmpty();
}
@Test
public void apply_drop_when_notInModel_then_ok() {
ModelContainer container = new ModelContainer();
DropTable dropTable = new DropTable();
dropTable.setName("DoesNotExist");
container.applyChange(dropTable);
DropIndex dropIndex = new DropIndex();
dropIndex.setIndexName("DoesNotExist");
container.applyChange(dropIndex);
DropHistoryTable dropHistoryTable = new DropHistoryTable();
dropHistoryTable.setBaseTable("DoesNotExist");
container.applyChange(dropHistoryTable);
}
private ModelContainer container_2_1() {
ModelContainer container = new ModelContainer();
container.apply(mig("2.0.model.xml"), ver("2.0"));