mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-10-23 14:32:04 +00:00
#1439 - IllegalArgumentException: No rule for io.ebeaninternal.dbmigration.migration.Sql@315df4bb
This commit is contained in:
@@ -17,6 +17,7 @@ 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.migration.Sql;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@@ -143,6 +144,8 @@ public class ModelContainer {
|
||||
applyChange((AlterForeignKey) change);
|
||||
} else if (change instanceof AddTableComment) {
|
||||
applyChange((AddTableComment) change);
|
||||
} else if (change instanceof Sql) {
|
||||
// do nothing
|
||||
} else {
|
||||
throw new IllegalArgumentException("No rule for " + change);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class ModelContainerApplyTest {
|
||||
|
||||
@Test
|
||||
public void testApply() throws Exception {
|
||||
public void testApply() {
|
||||
|
||||
Migration migration = MigrationXmlReader.read("/container/test-create-table.xml");
|
||||
|
||||
|
||||
@@ -12,17 +12,16 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class ModelContainerTest {
|
||||
|
||||
@Test
|
||||
public void apply_when_noPendingDrops_then_emptyPending() throws Exception {
|
||||
public void apply_when_noPendingDrops_then_emptyPending() {
|
||||
|
||||
ModelContainer container = new ModelContainer();
|
||||
container.apply(mig("1.0.model.xml"), ver("1.1"));
|
||||
|
||||
assertThat(container.getPendingDrops()).isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void apply_when_pendingDrops_then_registeredHistoryTable() throws Exception {
|
||||
public void apply_when_pendingDrops_then_registeredHistoryTable() {
|
||||
|
||||
ModelContainer base = container_1_1();
|
||||
|
||||
@@ -36,7 +35,7 @@ public class ModelContainerTest {
|
||||
|
||||
|
||||
@Test
|
||||
public void apply_when_pendingDropsApplied_then_droppedTableNotInHistory() throws Exception {
|
||||
public void apply_when_pendingDropsApplied_then_droppedTableNotInHistory() {
|
||||
|
||||
ModelContainer container = container_1_1();
|
||||
container.apply(mig("1.1_2__drops.model.xml"), ver("1.1_2"));
|
||||
@@ -50,7 +49,7 @@ public class ModelContainerTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void apply_when_apply_partial_pendingDrops_then_some_remainder() throws Exception {
|
||||
public void apply_when_apply_partial_pendingDrops_then_some_remainder() {
|
||||
|
||||
ModelContainer container = container_2_1();
|
||||
container.apply(mig("2.2__drops.model.xml"), ver("2.2"));
|
||||
@@ -66,6 +65,13 @@ public class ModelContainerTest {
|
||||
assertThat(normalColumns).doesNotContain("zing", "zong", "boom", "baz", "bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void apply_sql() {
|
||||
ModelContainer container = new ModelContainer();
|
||||
container.apply(mig("3.0__rawSql.model.xml"), ver("3.0"));
|
||||
assertThat(container.getPendingDrops()).isEmpty();
|
||||
}
|
||||
|
||||
private ModelContainer container_2_1() {
|
||||
ModelContainer container = new ModelContainer();
|
||||
container.apply(mig("2.0.model.xml"), ver("2.0"));
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
|
||||
<changeSet type="apply">
|
||||
<sql>
|
||||
<apply>something</apply>
|
||||
<rollback>other thing</rollback>
|
||||
</sql>
|
||||
</changeSet>
|
||||
</migration>
|
||||
Reference in New Issue
Block a user