diff --git a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/ModelDiff.java b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/ModelDiff.java index 1ba81b249..03560c822 100644 --- a/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/ModelDiff.java +++ b/ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/model/ModelDiff.java @@ -1,5 +1,6 @@ package io.ebeaninternal.dbmigration.model; +import io.ebeaninternal.dbmigration.ddlgeneration.platform.DdlHelp; import io.ebeaninternal.dbmigration.migration.*; import java.util.ArrayList; @@ -125,6 +126,21 @@ public class ModelDiff { // search for tables that are no longer used for (MTable existingTable : baseModel.getTables().values()) { if (!newTables.containsKey(existingTable.getName())) { + // Compounded foreign keys used in many-to-many mapping tables + existingTable.getCompoundKeys().forEach(it -> addAlterForeignKey(it.dropForeignKey(existingTable.getName()))); + // Foreign keys through direct mapping (oneToMany) + existingTable.allColumns().stream() + .filter(it -> it.getForeignKeyIndex() != null) + .map(it -> { + AlterForeignKey fk = new AlterForeignKey(); + fk.setName(it.getForeignKeyName()); + fk.setIndexName(it.getForeignKeyIndex()); + fk.setColumnNames(DdlHelp.DROP_FOREIGN_KEY); + fk.setTableName(existingTable.getName()); + return fk; + }) + .forEach(applyChanges::add); + addDropTable(existingTable); } } diff --git a/ebean-test/src/test/java/misc/migration/v1_0/DropMain.java b/ebean-test/src/test/java/misc/migration/v1_0/DropMain.java new file mode 100644 index 000000000..da7e6a250 --- /dev/null +++ b/ebean-test/src/test/java/misc/migration/v1_0/DropMain.java @@ -0,0 +1,48 @@ +package misc.migration.v1_0; + +import javax.persistence.*; +import java.util.List; + +/** + * Test-model referencing two other tables, which gets dropped for migration test in order to check for correct table drop + * procedure (first drop foreign keys, then the tables). + * + * @author Jonas Pöhler, FOCONIS AG + */ +@Entity +@Table(name = "drop_main") +public class DropMain { + + @Id + Integer id; + + @OneToMany(cascade = CascadeType.ALL, mappedBy = "parent") + List refsOne; + + @ManyToMany(cascade = CascadeType.ALL) + List refsMany; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public List getRefsOne() { + return refsOne; + } + + public void setRefsOne(List refsOne) { + this.refsOne = refsOne; + } + + public List getRefsMany() { + return refsMany; + } + + public void setRefsMany(List refsMany) { + this.refsMany = refsMany; + } +} diff --git a/ebean-test/src/test/java/misc/migration/v1_0/DropRefMany.java b/ebean-test/src/test/java/misc/migration/v1_0/DropRefMany.java new file mode 100644 index 000000000..a3727d5c2 --- /dev/null +++ b/ebean-test/src/test/java/misc/migration/v1_0/DropRefMany.java @@ -0,0 +1,35 @@ +package misc.migration.v1_0; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToMany; +import javax.persistence.ManyToOne; +import javax.persistence.Table; +import java.util.List; + +@Entity +@Table(name = "drop_ref_many") +public class DropRefMany { + + @Id + Integer id; + + @ManyToMany(cascade = {}, mappedBy = "refsMany") + List parents; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public List getParents() { + return parents; + } + + public void setParents(List parents) { + this.parents = parents; + } +} diff --git a/ebean-test/src/test/java/misc/migration/v1_0/DropRefOne.java b/ebean-test/src/test/java/misc/migration/v1_0/DropRefOne.java new file mode 100644 index 000000000..069b9274d --- /dev/null +++ b/ebean-test/src/test/java/misc/migration/v1_0/DropRefOne.java @@ -0,0 +1,33 @@ +package misc.migration.v1_0; + +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.ManyToOne; +import javax.persistence.Table; + +@Entity +@Table(name = "drop_ref_one") +public class DropRefOne { + + @Id + Integer id; + + @ManyToOne(cascade = {}) + DropMain parent; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public DropMain getParent() { + return parent; + } + + public void setParent(DropMain parent) { + this.parent = parent; + } +} diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql index 228422449..3c8ce6567 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql @@ -45,6 +45,24 @@ create table migtest_fk_set_null ( one_id UInt64 ) ENGINE = Log(); +create table drop_main ( + id UInt32 +) ENGINE = Log(); + +create table drop_main_drop_ref_many ( + drop_main_id UInt32, + drop_ref_many_id UInt32 +) ENGINE = Log(); + +create table drop_ref_many ( + id UInt32 +) ENGINE = Log(); + +create table drop_ref_one ( + id UInt32, + parent_id UInt32 +) ENGINE = Log(); + create table migtest_e_basic ( id UInt32, status String, diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.2__dropsFor_1.1.sql index cb6860e63..5934a713a 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.2__dropsFor_1.1.sql @@ -7,5 +7,9 @@ alter table migtest_e_basic drop column eref_id; alter table migtest_e_history2 drop column obsolete_string1; alter table migtest_e_history2 drop column obsolete_string2; -- apply post alter +drop table if exists drop_main; +drop table if exists drop_main_drop_ref_many; +drop table if exists drop_ref_many; +drop table if exists drop_ref_one; drop table if exists "migtest_QuOtEd"; drop table if exists migtest_e_ref; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations index 15a78f72e..b1ff6021b 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations @@ -1,6 +1,6 @@ -193400547, 1.0__initial.sql +1672735407, 1.0__initial.sql 540706946, 1.1.sql -688811494, 1.2__dropsFor_1.1.sql +-875723380, 1.2__dropsFor_1.1.sql 1015552567, 1.3.sql 255653518, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.0__initial.sql index 4f47e0774..79a5c4329 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer generated by default as identity not null, status varchar(1), @@ -193,6 +215,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.1.sql index 183dcdc71..c245c07b9 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.1.sql @@ -7,6 +7,9 @@ alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2 drop index uq_migtest_e_basic_indextest2 cascade; drop index uq_migtest_e_basic_indextest6 cascade; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table if exists drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_main; +alter table if exists drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_ref_many; +alter table if exists drop_ref_one drop constraint if exists fk_drop_ref_one_parent_id; drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.2__dropsFor_1.1.sql index 44f13ac12..5fc81acf1 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.2__dropsFor_1.1.sql @@ -7,6 +7,13 @@ alter table migtest_e_basic drop column eref_id; alter table migtest_e_history2 drop column obsolete_string1; alter table migtest_e_history2 drop column obsolete_string2; -- apply post alter +drop table if exists drop_main cascade; +drop sequence if exists drop_main_seq; +drop table if exists drop_main_drop_ref_many cascade; +drop table if exists drop_ref_many cascade; +drop sequence if exists drop_ref_many_seq; +drop table if exists drop_ref_one cascade; +drop sequence if exists drop_ref_one_seq; drop table if exists "migtest_QuOtEd" cascade; drop table if exists migtest_e_ref cascade; drop sequence if exists migtest_e_ref_seq; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.3.sql index 88945c112..67ff8ef72 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.3.sql @@ -14,6 +14,11 @@ drop index uq_migtest_e_basic_name cascade; drop index uq_migtest_e_basic_indextest4 cascade; drop index uq_migtest_e_basic_indextest5 cascade; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table if exists migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +alter table if exists migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +alter table if exists migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +alter table if exists migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +alter table if exists migtest_mtm_m_phone_numbers drop constraint if exists fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; drop index if exists ix_migtest_e_basic_indextest3; drop index if exists ix_migtest_e_basic_indextest6; drop index if exists ix_table_textfield2; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/idx_cockroach.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/idx_cockroach.migrations index debd08772..f3e4ced0c 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/idx_cockroach.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/idx_cockroach.migrations @@ -1,7 +1,7 @@ -1434934404, 1.0__initial.sql -1284257915, 1.1.sql -856096334, 1.2__dropsFor_1.1.sql --1551362011, 1.3.sql +1867456246, 1.0__initial.sql +-412570267, 1.1.sql +395394572, 1.2__dropsFor_1.1.sql +-861259583, 1.3.sql -971909974, 1.4__dropsFor_1.3.sql 561281075, R__order_views.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.0__initial.sql index 9931da4b1..b4660d18f 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer generated by default as identity not null, status varchar(1), @@ -232,6 +254,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.1.sql index 3032d4353..dbc55894f 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.1.sql @@ -65,6 +65,27 @@ end if; end$$; delimiter $$ begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_DROP_MAIN_DROP_REF_MANY_DROP_MAIN' and ucase(tabname) = 'DROP_MAIN_DROP_REF_MANY') then + prepare stmt from 'alter table drop_main_drop_ref_many drop constraint fk_drop_main_drop_ref_many_drop_main'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_DROP_MAIN_DROP_REF_MANY_DROP_REF_MANY' and ucase(tabname) = 'DROP_MAIN_DROP_REF_MANY') then + prepare stmt from 'alter table drop_main_drop_ref_many drop constraint fk_drop_main_drop_ref_many_drop_ref_many'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_DROP_REF_ONE_PARENT_ID' and ucase(tabname) = 'DROP_REF_ONE') then + prepare stmt from 'alter table drop_ref_one drop constraint fk_drop_ref_one_parent_id'; + execute stmt; +end if; +end$$; +delimiter $$ +begin if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_MIGTEST_E_BASIC_INDEXTEST1') then prepare stmt from 'drop index ix_migtest_e_basic_indextest1'; execute stmt; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.2__dropsFor_1.1.sql index 28b8850d6..f671f86d2 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.2__dropsFor_1.1.sql @@ -15,6 +15,31 @@ alter table migtest_e_history2_history drop column obsolete_string2; call sysproc.admin_cmd('reorg table migtest_e_history2_history'); -- apply post alter alter table migtest_e_history2 add versioning use history table migtest_e_history2_history; +drop table drop_main; +delimiter $$ +begin +if exists (select seqschema from syscat.sequences where seqschema = current_schema and ucase(seqname) = 'DROP_MAIN_SEQ') then + prepare stmt from 'drop sequence drop_main_seq'; + execute stmt; +end if; +end$$; +drop table drop_main_drop_ref_many; +drop table drop_ref_many; +delimiter $$ +begin +if exists (select seqschema from syscat.sequences where seqschema = current_schema and ucase(seqname) = 'DROP_REF_MANY_SEQ') then + prepare stmt from 'drop sequence drop_ref_many_seq'; + execute stmt; +end if; +end$$; +drop table drop_ref_one; +delimiter $$ +begin +if exists (select seqschema from syscat.sequences where seqschema = current_schema and ucase(seqname) = 'DROP_REF_ONE_SEQ') then + prepare stmt from 'drop sequence drop_ref_one_seq'; + execute stmt; +end if; +end$$; drop table "migtest_QuOtEd"; drop table migtest_e_ref; delimiter $$ diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.3.sql index 5baddc80a..9864c4f79 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.3.sql @@ -135,6 +135,41 @@ end if; end$$; delimiter $$ begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MIGTEST_MTM_C_MIGTEST_MTM_M_MIGTEST_MTM_C' and ucase(tabname) = 'MIGTEST_MTM_C_MIGTEST_MTM_M') then + prepare stmt from 'alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MIGTEST_MTM_C_MIGTEST_MTM_M_MIGTEST_MTM_M' and ucase(tabname) = 'MIGTEST_MTM_C_MIGTEST_MTM_M') then + prepare stmt from 'alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MIGTEST_MTM_M_MIGTEST_MTM_C_MIGTEST_MTM_M' and ucase(tabname) = 'MIGTEST_MTM_M_MIGTEST_MTM_C') then + prepare stmt from 'alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MIGTEST_MTM_M_MIGTEST_MTM_C_MIGTEST_MTM_C' and ucase(tabname) = 'MIGTEST_MTM_M_MIGTEST_MTM_C') then + prepare stmt from 'alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MIGTEST_MTM_M_PHONE_NUMBERS_MIGTEST_MTM_M_ID' and ucase(tabname) = 'MIGTEST_MTM_M_PHONE_NUMBERS') then + prepare stmt from 'alter table migtest_mtm_m_phone_numbers drop constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id'; + execute stmt; +end if; +end$$; +delimiter $$ +begin if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_MIGTEST_E_BASIC_INDEXTEST3') then prepare stmt from 'drop index ix_migtest_e_basic_indextest3'; execute stmt; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/idx_db2.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/idx_db2.migrations index 16c7b2cec..786fdf1ff 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/idx_db2.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/idx_db2.migrations @@ -1,7 +1,7 @@ --1467839063, 1.0__initial.sql --184000413, 1.1.sql --1187336846, 1.2__dropsFor_1.1.sql --150875853, 1.3.sql +-283216660, 1.0__initial.sql +1120848440, 1.1.sql +135256939, 1.2__dropsFor_1.1.sql +-2139056187, 1.3.sql 946163478, 1.4__dropsFor_1.3.sql 561281075, R__order_views.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.0__initial.sql index 7b7bddd1d..1490ff004 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer auto_increment not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer auto_increment not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer auto_increment not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer auto_increment not null, status varchar(1), @@ -194,6 +216,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.1.sql index 645d357f2..cb3cb88ad 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.1.sql @@ -7,6 +7,9 @@ alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2 alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_main; +alter table drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_ref_many; +alter table drop_ref_one drop constraint if exists fk_drop_ref_one_parent_id; drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.2__dropsFor_1.1.sql index cb6860e63..5934a713a 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.2__dropsFor_1.1.sql @@ -7,5 +7,9 @@ alter table migtest_e_basic drop column eref_id; alter table migtest_e_history2 drop column obsolete_string1; alter table migtest_e_history2 drop column obsolete_string2; -- apply post alter +drop table if exists drop_main; +drop table if exists drop_main_drop_ref_many; +drop table if exists drop_ref_many; +drop table if exists drop_ref_one; drop table if exists "migtest_QuOtEd"; drop table if exists migtest_e_ref; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.3.sql index d41f2877a..63f9580db 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.3.sql @@ -14,6 +14,11 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_name; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +alter table migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +alter table migtest_mtm_m_phone_numbers drop constraint if exists fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; drop index if exists ix_migtest_e_basic_indextest3; drop index if exists ix_migtest_e_basic_indextest6; drop index if exists ix_table_textfield2; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_generic.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_generic.migrations index c9faf50c4..74218a1a6 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_generic.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_generic.migrations @@ -1,6 +1,6 @@ --1547037623, 1.0__initial.sql -253988246, 1.1.sql -688811494, 1.2__dropsFor_1.1.sql -509168727, 1.3.sql +-528359263, 1.0__initial.sql +-1374084944, 1.1.sql +-875723380, 1.2__dropsFor_1.1.sql +-819139044, 1.3.sql 255653518, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.0__initial.sql index 8b9d60aad..132b608f7 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer generated by default as identity not null, status varchar(1), @@ -232,6 +254,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.1.sql index 2f4beedaa..ab12314e5 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.1.sql @@ -65,6 +65,27 @@ end if; end$$; delimiter $$ begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_DROP_MAIN_DROP_REF_MANY_DROP_MAIN' and ucase(tabname) = 'DROP_MAIN_DROP_REF_MANY') then + prepare stmt from 'alter table drop_main_drop_ref_many drop constraint fk_drop_main_drop_ref_many_drop_main'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_DROP_MAIN_DROP_REF_MANY_DROP_REF_MANY' and ucase(tabname) = 'DROP_MAIN_DROP_REF_MANY') then + prepare stmt from 'alter table drop_main_drop_ref_many drop constraint fk_drop_main_drop_ref_many_drop_ref_many'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_DROP_REF_ONE_PARENT_ID' and ucase(tabname) = 'DROP_REF_ONE') then + prepare stmt from 'alter table drop_ref_one drop constraint fk_drop_ref_one_parent_id'; + execute stmt; +end if; +end$$; +delimiter $$ +begin if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_MIGTEST_E_BASIC_INDEXTEST1') then prepare stmt from 'drop index ix_migtest_e_basic_indextest1'; execute stmt; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.2__dropsFor_1.1.sql index 28b8850d6..f671f86d2 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.2__dropsFor_1.1.sql @@ -15,6 +15,31 @@ alter table migtest_e_history2_history drop column obsolete_string2; call sysproc.admin_cmd('reorg table migtest_e_history2_history'); -- apply post alter alter table migtest_e_history2 add versioning use history table migtest_e_history2_history; +drop table drop_main; +delimiter $$ +begin +if exists (select seqschema from syscat.sequences where seqschema = current_schema and ucase(seqname) = 'DROP_MAIN_SEQ') then + prepare stmt from 'drop sequence drop_main_seq'; + execute stmt; +end if; +end$$; +drop table drop_main_drop_ref_many; +drop table drop_ref_many; +delimiter $$ +begin +if exists (select seqschema from syscat.sequences where seqschema = current_schema and ucase(seqname) = 'DROP_REF_MANY_SEQ') then + prepare stmt from 'drop sequence drop_ref_many_seq'; + execute stmt; +end if; +end$$; +drop table drop_ref_one; +delimiter $$ +begin +if exists (select seqschema from syscat.sequences where seqschema = current_schema and ucase(seqname) = 'DROP_REF_ONE_SEQ') then + prepare stmt from 'drop sequence drop_ref_one_seq'; + execute stmt; +end if; +end$$; drop table "migtest_QuOtEd"; drop table migtest_e_ref; delimiter $$ diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.3.sql index 4a672dd72..f9e79df78 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.3.sql @@ -135,6 +135,41 @@ end if; end$$; delimiter $$ begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MIGTEST_MTM_C_MIGTEST_MTM_M_MIGTEST_MTM_C' and ucase(tabname) = 'MIGTEST_MTM_C_MIGTEST_MTM_M') then + prepare stmt from 'alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MIGTEST_MTM_C_MIGTEST_MTM_M_MIGTEST_MTM_M' and ucase(tabname) = 'MIGTEST_MTM_C_MIGTEST_MTM_M') then + prepare stmt from 'alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MIGTEST_MTM_M_MIGTEST_MTM_C_MIGTEST_MTM_M' and ucase(tabname) = 'MIGTEST_MTM_M_MIGTEST_MTM_C') then + prepare stmt from 'alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MIGTEST_MTM_M_MIGTEST_MTM_C_MIGTEST_MTM_C' and ucase(tabname) = 'MIGTEST_MTM_M_MIGTEST_MTM_C') then + prepare stmt from 'alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MIGTEST_MTM_M_PHONE_NUMBERS_MIGTEST_MTM_M_ID' and ucase(tabname) = 'MIGTEST_MTM_M_PHONE_NUMBERS') then + prepare stmt from 'alter table migtest_mtm_m_phone_numbers drop constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id'; + execute stmt; +end if; +end$$; +delimiter $$ +begin if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_MIGTEST_E_BASIC_INDEXTEST3') then prepare stmt from 'drop index ix_migtest_e_basic_indextest3'; execute stmt; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/idx_db2.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/idx_db2.migrations index 146c2c1d8..195e14753 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/idx_db2.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/idx_db2.migrations @@ -1,8 +1,8 @@ 1307787475, I__create_tablespaces.sql -2058232717, 1.0__initial.sql --1450326352, 1.1.sql --1187336846, 1.2__dropsFor_1.1.sql -1976888196, 1.3.sql +1681764655, 1.0__initial.sql +1259437403, 1.1.sql +135256939, 1.2__dropsFor_1.1.sql +1091218936, 1.3.sql 946163478, 1.4__dropsFor_1.3.sql 561281075, R__order_views.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.0__initial.sql index 8b9d60aad..132b608f7 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer generated by default as identity not null, status varchar(1), @@ -232,6 +254,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.1.sql index 2f4beedaa..ab12314e5 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.1.sql @@ -65,6 +65,27 @@ end if; end$$; delimiter $$ begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_DROP_MAIN_DROP_REF_MANY_DROP_MAIN' and ucase(tabname) = 'DROP_MAIN_DROP_REF_MANY') then + prepare stmt from 'alter table drop_main_drop_ref_many drop constraint fk_drop_main_drop_ref_many_drop_main'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_DROP_MAIN_DROP_REF_MANY_DROP_REF_MANY' and ucase(tabname) = 'DROP_MAIN_DROP_REF_MANY') then + prepare stmt from 'alter table drop_main_drop_ref_many drop constraint fk_drop_main_drop_ref_many_drop_ref_many'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_DROP_REF_ONE_PARENT_ID' and ucase(tabname) = 'DROP_REF_ONE') then + prepare stmt from 'alter table drop_ref_one drop constraint fk_drop_ref_one_parent_id'; + execute stmt; +end if; +end$$; +delimiter $$ +begin if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_MIGTEST_E_BASIC_INDEXTEST1') then prepare stmt from 'drop index ix_migtest_e_basic_indextest1'; execute stmt; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.2__dropsFor_1.1.sql index 28b8850d6..f671f86d2 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.2__dropsFor_1.1.sql @@ -15,6 +15,31 @@ alter table migtest_e_history2_history drop column obsolete_string2; call sysproc.admin_cmd('reorg table migtest_e_history2_history'); -- apply post alter alter table migtest_e_history2 add versioning use history table migtest_e_history2_history; +drop table drop_main; +delimiter $$ +begin +if exists (select seqschema from syscat.sequences where seqschema = current_schema and ucase(seqname) = 'DROP_MAIN_SEQ') then + prepare stmt from 'drop sequence drop_main_seq'; + execute stmt; +end if; +end$$; +drop table drop_main_drop_ref_many; +drop table drop_ref_many; +delimiter $$ +begin +if exists (select seqschema from syscat.sequences where seqschema = current_schema and ucase(seqname) = 'DROP_REF_MANY_SEQ') then + prepare stmt from 'drop sequence drop_ref_many_seq'; + execute stmt; +end if; +end$$; +drop table drop_ref_one; +delimiter $$ +begin +if exists (select seqschema from syscat.sequences where seqschema = current_schema and ucase(seqname) = 'DROP_REF_ONE_SEQ') then + prepare stmt from 'drop sequence drop_ref_one_seq'; + execute stmt; +end if; +end$$; drop table "migtest_QuOtEd"; drop table migtest_e_ref; delimiter $$ diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.3.sql index 4a672dd72..f9e79df78 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.3.sql @@ -135,6 +135,41 @@ end if; end$$; delimiter $$ begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MIGTEST_MTM_C_MIGTEST_MTM_M_MIGTEST_MTM_C' and ucase(tabname) = 'MIGTEST_MTM_C_MIGTEST_MTM_M') then + prepare stmt from 'alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MIGTEST_MTM_C_MIGTEST_MTM_M_MIGTEST_MTM_M' and ucase(tabname) = 'MIGTEST_MTM_C_MIGTEST_MTM_M') then + prepare stmt from 'alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MIGTEST_MTM_M_MIGTEST_MTM_C_MIGTEST_MTM_M' and ucase(tabname) = 'MIGTEST_MTM_M_MIGTEST_MTM_C') then + prepare stmt from 'alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MIGTEST_MTM_M_MIGTEST_MTM_C_MIGTEST_MTM_C' and ucase(tabname) = 'MIGTEST_MTM_M_MIGTEST_MTM_C') then + prepare stmt from 'alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and ucase(constname) = 'FK_MIGTEST_MTM_M_PHONE_NUMBERS_MIGTEST_MTM_M_ID' and ucase(tabname) = 'MIGTEST_MTM_M_PHONE_NUMBERS') then + prepare stmt from 'alter table migtest_mtm_m_phone_numbers drop constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id'; + execute stmt; +end if; +end$$; +delimiter $$ +begin if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_MIGTEST_E_BASIC_INDEXTEST3') then prepare stmt from 'drop index ix_migtest_e_basic_indextest3'; execute stmt; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/idx_db2.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/idx_db2.migrations index 2d8e70ad2..618846ffe 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/idx_db2.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/idx_db2.migrations @@ -1,7 +1,7 @@ -2058232717, 1.0__initial.sql --1450326352, 1.1.sql --1187336846, 1.2__dropsFor_1.1.sql -1976888196, 1.3.sql +1681764655, 1.0__initial.sql +1259437403, 1.1.sql +135256939, 1.2__dropsFor_1.1.sql +1091218936, 1.3.sql 946163478, 1.4__dropsFor_1.3.sql 561281075, R__order_views.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.0__initial.sql index 7b7bddd1d..1490ff004 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer auto_increment not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer auto_increment not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer auto_increment not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer auto_increment not null, status varchar(1), @@ -194,6 +216,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.1.sql index 645d357f2..cb3cb88ad 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.1.sql @@ -7,6 +7,9 @@ alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2 alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_main; +alter table drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_ref_many; +alter table drop_ref_one drop constraint if exists fk_drop_ref_one_parent_id; drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.2__dropsFor_1.1.sql index cb6860e63..5934a713a 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.2__dropsFor_1.1.sql @@ -7,5 +7,9 @@ alter table migtest_e_basic drop column eref_id; alter table migtest_e_history2 drop column obsolete_string1; alter table migtest_e_history2 drop column obsolete_string2; -- apply post alter +drop table if exists drop_main; +drop table if exists drop_main_drop_ref_many; +drop table if exists drop_ref_many; +drop table if exists drop_ref_one; drop table if exists "migtest_QuOtEd"; drop table if exists migtest_e_ref; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.3.sql index d41f2877a..63f9580db 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.3.sql @@ -14,6 +14,11 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_name; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +alter table migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +alter table migtest_mtm_m_phone_numbers drop constraint if exists fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; drop index if exists ix_migtest_e_basic_indextest3; drop index if exists ix_migtest_e_basic_indextest6; drop index if exists ix_table_textfield2; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/idx_generic.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/idx_generic.migrations index c9faf50c4..74218a1a6 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/idx_generic.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/idx_generic.migrations @@ -1,6 +1,6 @@ --1547037623, 1.0__initial.sql -253988246, 1.1.sql -688811494, 1.2__dropsFor_1.1.sql -509168727, 1.3.sql +-528359263, 1.0__initial.sql +-1374084944, 1.1.sql +-875723380, 1.2__dropsFor_1.1.sql +-819139044, 1.3.sql 255653518, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.0__initial.sql index d405e6e70..93a101a08 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer generated by default as identity not null, status varchar(1), @@ -269,6 +291,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.1.sql index 93ae665e6..afb910c0b 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.1.sql @@ -7,6 +7,9 @@ alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2 alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_main; +alter table drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_ref_many; +alter table drop_ref_one drop constraint if exists fk_drop_ref_one_parent_id; drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.2__dropsFor_1.1.sql index a0c8ec44b..d270bde5e 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.2__dropsFor_1.1.sql @@ -14,6 +14,13 @@ alter table migtest_e_history2_history drop column obsolete_string2; -- apply post alter create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.platform.h2.H2HistoryTrigger"; +drop table if exists drop_main; +drop sequence if exists drop_main_seq; +drop table if exists drop_main_drop_ref_many; +drop table if exists drop_ref_many; +drop sequence if exists drop_ref_many_seq; +drop table if exists drop_ref_one; +drop sequence if exists drop_ref_one_seq; drop table if exists "migtest_QuOtEd"; drop table if exists migtest_e_ref; drop sequence if exists migtest_e_ref_seq; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.3.sql index 844fb66bd..14d847530 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.3.sql @@ -14,6 +14,11 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_name; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +alter table migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +alter table migtest_mtm_m_phone_numbers drop constraint if exists fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; drop index if exists ix_migtest_e_basic_indextest3; drop index if exists ix_migtest_e_basic_indextest6; drop index if exists ix_table_textfield2; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/idx_h2.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/idx_h2.migrations index a58bd9139..ad8f05cb2 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/idx_h2.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/idx_h2.migrations @@ -1,7 +1,7 @@ --1854589550, 1.0__initial.sql -1979519453, 1.1.sql -1579867974, 1.2__dropsFor_1.1.sql --285485598, 1.3.sql +400361768, 1.0__initial.sql +1531147865, 1.1.sql +2123154375, 1.2__dropsFor_1.1.sql +363782261, 1.3.sql -1120611041, 1.4__dropsFor_1.3.sql 783227075, R__multi_comments.sql 561281075, R__order_views.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.0__initial.sql index 2c4188555..b42347e19 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.0__initial.sql @@ -54,6 +54,28 @@ create column table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create column table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create column table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create column table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create column table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create column table migtest_e_basic ( id integer generated by default as identity not null, status nvarchar(1), @@ -275,6 +297,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei -- explicit index "ix_migtest_fk_set_null_one_id" for single column "one_id" of table "migtest_fk_set_null" is not necessary; alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +-- explicit index "ix_drop_main_drop_ref_many_drop_main" for single column "drop_main_id" of table "drop_main_drop_ref_many" is not necessary; +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +-- explicit index "ix_drop_main_drop_ref_many_drop_ref_many" for single column "drop_ref_many_id" of table "drop_main_drop_ref_many" is not necessary; +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +-- explicit index "ix_drop_ref_one_parent_id" for single column "parent_id" of table "drop_ref_one" is not necessary; +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + -- explicit index "ix_migtest_e_basic_eref_id" for single column "eref_id" of table "migtest_e_basic" is not necessary; alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.1.sql index 98d826685..fe2af578a 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.1.sql @@ -37,6 +37,9 @@ declare exit handler for sql_error_code 397 begin end; exec 'alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status'; end; $$; +alter table drop_main_drop_ref_many drop constraint fk_drop_main_drop_ref_many_drop_main; +alter table drop_main_drop_ref_many drop constraint fk_drop_main_drop_ref_many_drop_ref_many; +alter table drop_ref_one drop constraint fk_drop_ref_one_parent_id; delimiter $$ do begin diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.2__dropsFor_1.1.sql index b5fe0f04f..6fcca7c67 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.2__dropsFor_1.1.sql @@ -12,5 +12,9 @@ CALL usp_ebean_drop_column('migtest_e_history2_history', 'obsolete_string1'); CALL usp_ebean_drop_column('migtest_e_history2_history', 'obsolete_string2'); -- apply post alter alter table migtest_e_history2 add system versioning history table migtest_e_history2_history not validated; +drop table drop_main cascade; +drop table drop_main_drop_ref_many cascade; +drop table drop_ref_many cascade; +drop table drop_ref_one cascade; drop table "migtest_QuOtEd" cascade; drop table migtest_e_ref cascade; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.3.sql index e818117ed..a06064e3d 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.3.sql @@ -62,6 +62,11 @@ declare exit handler for sql_error_code 397 begin end; exec 'alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status'; end; $$; +alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +alter table migtest_mtm_m_phone_numbers drop constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; delimiter $$ do begin diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/idx_hana.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/idx_hana.migrations index 467fc71ec..935bc4cf2 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/idx_hana.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/idx_hana.migrations @@ -1,8 +1,8 @@ -745347271, I__create_procs.sql --2017770851, 1.0__initial.sql --1727762906, 1.1.sql -1535221752, 1.2__dropsFor_1.1.sql --1046661128, 1.3.sql +-1399184401, 1.0__initial.sql +-1126493787, 1.1.sql +-1209748806, 1.2__dropsFor_1.1.sql +-657475021, 1.3.sql 1185007986, 1.4__dropsFor_1.3.sql 1906063401, R__order_views_hana.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.0__initial.sql index ff2f34299..90807ee40 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer generated by default as identity (start with 1) not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity (start with 1) not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity (start with 1) not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer generated by default as identity (start with 1) not null, status varchar(1), @@ -194,6 +216,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.1.sql index 94010fa00..4f53eb7cd 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.1.sql @@ -7,6 +7,9 @@ alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2 alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_main; +alter table drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_ref_many; +alter table drop_ref_one drop constraint if exists fk_drop_ref_one_parent_id; drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.2__dropsFor_1.1.sql index eeb8a6a1c..25d0b60d8 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.2__dropsFor_1.1.sql @@ -7,6 +7,13 @@ alter table migtest_e_basic drop column eref_id; alter table migtest_e_history2 drop column obsolete_string1; alter table migtest_e_history2 drop column obsolete_string2; -- apply post alter +drop table if exists drop_main; +drop sequence if exists drop_main_seq; +drop table if exists drop_main_drop_ref_many; +drop table if exists drop_ref_many; +drop sequence if exists drop_ref_many_seq; +drop table if exists drop_ref_one; +drop sequence if exists drop_ref_one_seq; drop table if exists "migtest_QuOtEd"; drop table if exists migtest_e_ref; drop sequence if exists migtest_e_ref_seq; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.3.sql index 3d4fb1409..523838fb0 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.3.sql @@ -14,6 +14,11 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_name; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +alter table migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +alter table migtest_mtm_m_phone_numbers drop constraint if exists fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; drop index if exists ix_migtest_e_basic_indextest3; drop index if exists ix_migtest_e_basic_indextest6; drop index if exists ix_table_textfield2; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/idx_hsqldb.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/idx_hsqldb.migrations index 61c09dc8e..8c976d04a 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/idx_hsqldb.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/idx_hsqldb.migrations @@ -1,7 +1,7 @@ -1833930558, 1.0__initial.sql -84224587, 1.1.sql --848622216, 1.2__dropsFor_1.1.sql -19356381, 1.3.sql +617421105, 1.0__initial.sql +-271408671, 1.1.sql +1366518530, 1.2__dropsFor_1.1.sql +1536842100, 1.3.sql 1661935263, 1.4__dropsFor_1.3.sql 861001272, R__order_views_hsqldb.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.0__initial.sql index f9b1b3f43..18c10634b 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer auto_increment not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer auto_increment not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer auto_increment not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer auto_increment not null, status varchar(1), @@ -195,6 +217,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.1.sql index 4213de18e..25b6f2836 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.1.sql @@ -4,6 +4,9 @@ alter table migtest_fk_cascade drop foreign key fk_migtest_fk_cascade_one_id; alter table migtest_fk_set_null drop foreign key fk_migtest_fk_set_null_one_id; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest2; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest6; +alter table drop_main_drop_ref_many drop foreign key fk_drop_main_drop_ref_many_drop_main; +alter table drop_main_drop_ref_many drop foreign key fk_drop_main_drop_ref_many_drop_ref_many; +alter table drop_ref_one drop foreign key fk_drop_ref_one_parent_id; drop index ix_migtest_e_basic_indextest1 on migtest_e_basic; drop index ix_migtest_e_basic_indextest5 on migtest_e_basic; drop index ix_migtest_quoted_status1 on `migtest_QuOtEd`; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.2__dropsFor_1.1.sql index 60699805e..11a53de7f 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.2__dropsFor_1.1.sql @@ -9,6 +9,13 @@ alter table migtest_e_basic drop column eref_id; alter table migtest_e_history2 drop column obsolete_string1; alter table migtest_e_history2 drop column obsolete_string2; -- apply post alter +drop table if exists drop_main; +drop sequence if exists drop_main_seq; +drop table if exists drop_main_drop_ref_many; +drop table if exists drop_ref_many; +drop sequence if exists drop_ref_many_seq; +drop table if exists drop_ref_one; +drop sequence if exists drop_ref_one_seq; drop table if exists `migtest_QuOtEd`; drop table if exists migtest_e_ref; drop sequence if exists migtest_e_ref_seq; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.3.sql index 6fd34becb..cdf8b7589 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.3.sql @@ -11,6 +11,11 @@ alter table migtest_e_basic drop index uq_migtest_e_basic_status_indextest1; alter table migtest_e_basic drop index uq_migtest_e_basic_name; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest4; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest5; +alter table migtest_mtm_c_migtest_mtm_m drop foreign key fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +alter table migtest_mtm_c_migtest_mtm_m drop foreign key fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop foreign key fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop foreign key fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +alter table migtest_mtm_m_phone_numbers drop foreign key fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; drop index ix_migtest_e_basic_indextest3 on migtest_e_basic; drop index ix_migtest_e_basic_indextest6 on migtest_e_basic; drop index ix_table_textfield2 on `table`; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/idx_mariadb.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/idx_mariadb.migrations index 98022f4e3..8bbc74d7c 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/idx_mariadb.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/idx_mariadb.migrations @@ -1,7 +1,7 @@ --2111548334, 1.0__initial.sql --1101751768, 1.1.sql -919151678, 1.2__dropsFor_1.1.sql --1572621686, 1.3.sql +-1588268581, 1.0__initial.sql +993683171, 1.1.sql +-799907262, 1.2__dropsFor_1.1.sql +-797191406, 1.3.sql 1686135364, 1.4__dropsFor_1.3.sql 561281075, R__order_views.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.0__initial.sql index f9b1b3f43..18c10634b 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer auto_increment not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer auto_increment not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer auto_increment not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer auto_increment not null, status varchar(1), @@ -195,6 +217,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.1.sql index 4213de18e..25b6f2836 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.1.sql @@ -4,6 +4,9 @@ alter table migtest_fk_cascade drop foreign key fk_migtest_fk_cascade_one_id; alter table migtest_fk_set_null drop foreign key fk_migtest_fk_set_null_one_id; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest2; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest6; +alter table drop_main_drop_ref_many drop foreign key fk_drop_main_drop_ref_many_drop_main; +alter table drop_main_drop_ref_many drop foreign key fk_drop_main_drop_ref_many_drop_ref_many; +alter table drop_ref_one drop foreign key fk_drop_ref_one_parent_id; drop index ix_migtest_e_basic_indextest1 on migtest_e_basic; drop index ix_migtest_e_basic_indextest5 on migtest_e_basic; drop index ix_migtest_quoted_status1 on `migtest_QuOtEd`; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.2__dropsFor_1.1.sql index 8d64a0804..7ee0a4023 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.2__dropsFor_1.1.sql @@ -9,6 +9,13 @@ CALL usp_ebean_drop_column('migtest_e_basic', 'eref_id'); CALL usp_ebean_drop_column('migtest_e_history2', 'obsolete_string1'); CALL usp_ebean_drop_column('migtest_e_history2', 'obsolete_string2'); -- apply post alter +drop table if exists drop_main; +drop sequence if exists drop_main_seq; +drop table if exists drop_main_drop_ref_many; +drop table if exists drop_ref_many; +drop sequence if exists drop_ref_many_seq; +drop table if exists drop_ref_one; +drop sequence if exists drop_ref_one_seq; drop table if exists `migtest_QuOtEd`; drop table if exists migtest_e_ref; drop sequence if exists migtest_e_ref_seq; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.3.sql index 6fd34becb..cdf8b7589 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.3.sql @@ -11,6 +11,11 @@ alter table migtest_e_basic drop index uq_migtest_e_basic_status_indextest1; alter table migtest_e_basic drop index uq_migtest_e_basic_name; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest4; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest5; +alter table migtest_mtm_c_migtest_mtm_m drop foreign key fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +alter table migtest_mtm_c_migtest_mtm_m drop foreign key fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop foreign key fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop foreign key fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +alter table migtest_mtm_m_phone_numbers drop foreign key fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; drop index ix_migtest_e_basic_indextest3 on migtest_e_basic; drop index ix_migtest_e_basic_indextest6 on migtest_e_basic; drop index ix_table_textfield2 on `table`; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/idx_mariadb.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/idx_mariadb.migrations index 9b6cb159a..db5321181 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/idx_mariadb.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/idx_mariadb.migrations @@ -1,8 +1,8 @@ -1933396282, I__create_procs.sql --2111548334, 1.0__initial.sql --1101751768, 1.1.sql -1187950993, 1.2__dropsFor_1.1.sql --1572621686, 1.3.sql +-1588268581, 1.0__initial.sql +993683171, 1.1.sql +1653772183, 1.2__dropsFor_1.1.sql +-797191406, 1.3.sql 772508824, 1.4__dropsFor_1.3.sql 561281075, R__order_views.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.0__initial.model.xml b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.0__initial.model.xml index b0d93151a..d3b46df24 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.0__initial.model.xml +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.0__initial.model.xml @@ -37,6 +37,22 @@ + + + + + + + + + + + + + + + + diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.1.model.xml b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.1.model.xml index 1c704408c..c2c04f482 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.1.model.xml +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.1.model.xml @@ -103,6 +103,9 @@ + + + @@ -121,6 +124,10 @@ + + + + diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.2__dropsFor_1.1.model.xml b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.2__dropsFor_1.1.model.xml index 99fa64365..4a4eb166d 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.2__dropsFor_1.1.model.xml +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.2__dropsFor_1.1.model.xml @@ -7,6 +7,10 @@ + + + + diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.3.model.xml b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.3.model.xml index 8aac45e36..3b4b2aca4 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.3.model.xml +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.3.model.xml @@ -51,6 +51,11 @@ + + + + + diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.0__initial.sql index f2eb08f85..eb95f6816 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer auto_increment not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer auto_increment not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer auto_increment not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer auto_increment not null, status varchar(1), @@ -323,6 +345,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.1.sql index 2b8461633..b574bebf1 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.1.sql @@ -4,6 +4,9 @@ alter table migtest_fk_cascade drop foreign key fk_migtest_fk_cascade_one_id; alter table migtest_fk_set_null drop foreign key fk_migtest_fk_set_null_one_id; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest2; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest6; +alter table drop_main_drop_ref_many drop foreign key fk_drop_main_drop_ref_many_drop_main; +alter table drop_main_drop_ref_many drop foreign key fk_drop_main_drop_ref_many_drop_ref_many; +alter table drop_ref_one drop foreign key fk_drop_ref_one_parent_id; drop index ix_migtest_e_basic_indextest1 on migtest_e_basic; drop index ix_migtest_e_basic_indextest5 on migtest_e_basic; drop index ix_migtest_quoted_status1 on `migtest_QuOtEd`; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.2__dropsFor_1.1.sql index 2c06ee001..a9aee81d2 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.2__dropsFor_1.1.sql @@ -25,5 +25,9 @@ create trigger migtest_e_history2_history_del before delete on migtest_e_history insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, new_column) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column); end$$ unlock tables; +drop table if exists drop_main; +drop table if exists drop_main_drop_ref_many; +drop table if exists drop_ref_many; +drop table if exists drop_ref_one; drop table if exists `migtest_QuOtEd`; drop table if exists migtest_e_ref; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.3.sql index 410f3e719..50be0f46d 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.3.sql @@ -11,6 +11,11 @@ alter table migtest_e_basic drop index uq_migtest_e_basic_status_indextest1; alter table migtest_e_basic drop index uq_migtest_e_basic_name; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest4; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest5; +alter table migtest_mtm_c_migtest_mtm_m drop foreign key fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +alter table migtest_mtm_c_migtest_mtm_m drop foreign key fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop foreign key fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop foreign key fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +alter table migtest_mtm_m_phone_numbers drop foreign key fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; drop index ix_migtest_e_basic_indextest3 on migtest_e_basic; drop index ix_migtest_e_basic_indextest6 on migtest_e_basic; drop index ix_table_textfield2 on `table`; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/idx_mysql.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/idx_mysql.migrations index adf927e95..43099e790 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/idx_mysql.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/idx_mysql.migrations @@ -1,8 +1,8 @@ -1933396282, I__create_procs.sql -1980830787, 1.0__initial.sql --92753611, 1.1.sql --1097227916, 1.2__dropsFor_1.1.sql -1674664705, 1.3.sql +-1156696445, 1.0__initial.sql +-1306874760, 1.1.sql +-70834029, 1.2__dropsFor_1.1.sql +514784474, 1.3.sql -1282113429, 1.4__dropsFor_1.3.sql 561281075, R__order_views.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.0__initial.sql index b1db29fc1..7e6906ea4 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer auto_increment not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer auto_increment not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer auto_increment not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer auto_increment not null, status varchar(1), @@ -323,6 +345,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.1.sql index 2b8461633..b574bebf1 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.1.sql @@ -4,6 +4,9 @@ alter table migtest_fk_cascade drop foreign key fk_migtest_fk_cascade_one_id; alter table migtest_fk_set_null drop foreign key fk_migtest_fk_set_null_one_id; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest2; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest6; +alter table drop_main_drop_ref_many drop foreign key fk_drop_main_drop_ref_many_drop_main; +alter table drop_main_drop_ref_many drop foreign key fk_drop_main_drop_ref_many_drop_ref_many; +alter table drop_ref_one drop foreign key fk_drop_ref_one_parent_id; drop index ix_migtest_e_basic_indextest1 on migtest_e_basic; drop index ix_migtest_e_basic_indextest5 on migtest_e_basic; drop index ix_migtest_quoted_status1 on `migtest_QuOtEd`; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.2__dropsFor_1.1.sql index 2c06ee001..a9aee81d2 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.2__dropsFor_1.1.sql @@ -25,5 +25,9 @@ create trigger migtest_e_history2_history_del before delete on migtest_e_history insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, new_column) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column); end$$ unlock tables; +drop table if exists drop_main; +drop table if exists drop_main_drop_ref_many; +drop table if exists drop_ref_many; +drop table if exists drop_ref_one; drop table if exists `migtest_QuOtEd`; drop table if exists migtest_e_ref; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.3.sql index 410f3e719..50be0f46d 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.3.sql @@ -11,6 +11,11 @@ alter table migtest_e_basic drop index uq_migtest_e_basic_status_indextest1; alter table migtest_e_basic drop index uq_migtest_e_basic_name; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest4; alter table migtest_e_basic drop index uq_migtest_e_basic_indextest5; +alter table migtest_mtm_c_migtest_mtm_m drop foreign key fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +alter table migtest_mtm_c_migtest_mtm_m drop foreign key fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop foreign key fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop foreign key fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +alter table migtest_mtm_m_phone_numbers drop foreign key fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; drop index ix_migtest_e_basic_indextest3 on migtest_e_basic; drop index ix_migtest_e_basic_indextest6 on migtest_e_basic; drop index ix_table_textfield2 on `table`; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/idx_mysql.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/idx_mysql.migrations index bbf93e18d..b75635236 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/idx_mysql.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/idx_mysql.migrations @@ -1,8 +1,8 @@ -1933396282, I__create_procs.sql -369577572, 1.0__initial.sql --92753611, 1.1.sql --1097227916, 1.2__dropsFor_1.1.sql -1674664705, 1.3.sql +-165038024, 1.0__initial.sql +-1306874760, 1.1.sql +-70834029, 1.2__dropsFor_1.1.sql +514784474, 1.3.sql -1282113429, 1.4__dropsFor_1.3.sql 561281075, R__order_views.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.0__initial.sql index b5d81c5bd..58cfc41bb 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer generated by default as identity not null, status varchar(1), @@ -340,6 +362,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id); +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id); + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id); + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id); + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.1.sql index 31cdd3756..4684f5fcb 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.1.sql @@ -7,6 +7,9 @@ alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status; +alter table drop_main_drop_ref_many drop constraint fk_drop_main_drop_ref_many_drop_main; +alter table drop_main_drop_ref_many drop constraint fk_drop_main_drop_ref_many_drop_ref_many; +alter table drop_ref_one drop constraint fk_drop_ref_one_parent_id; drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.2__dropsFor_1.1.sql index fc0eb25e3..78bd786c6 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.2__dropsFor_1.1.sql @@ -27,6 +27,13 @@ create or replace trigger migtest_e_history2_history_del for migtest_e_history2 end_trigger; $$ +drop table if exists drop_main; +drop sequence if exists drop_main_seq; +drop table if exists drop_main_drop_ref_many; +drop table if exists drop_ref_many; +drop sequence if exists drop_ref_many_seq; +drop table if exists drop_ref_one; +drop sequence if exists drop_ref_one_seq; drop table if exists "migtest_QuOtEd"; drop table if exists migtest_e_ref; drop sequence if exists migtest_e_ref_seq; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.3.sql index ca422f7c7..ed90925e9 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.3.sql @@ -14,6 +14,11 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_name; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status; +alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +alter table migtest_mtm_m_phone_numbers drop constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; drop index if exists ix_migtest_e_basic_indextest3; drop index if exists ix_migtest_e_basic_indextest6; drop index if exists ix_table_textfield2; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/idx_nuodb.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/idx_nuodb.migrations index 1342d6508..223b29d61 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/idx_nuodb.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/idx_nuodb.migrations @@ -1,7 +1,7 @@ -390216918, 1.0__initial.sql --2079708895, 1.1.sql -1530685455, 1.2__dropsFor_1.1.sql -73983167, 1.3.sql +-588780599, 1.0__initial.sql +1864060880, 1.1.sql +-1061962041, 1.2__dropsFor_1.1.sql +-1346387712, 1.3.sql -1118858496, 1.4__dropsFor_1.3.sql 561281075, R__order_views.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.0__initial.sql index 4b2f1f9a5..a97688926 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id number(10) generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id number(10) not null, + drop_ref_many_id number(10) not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id number(10) generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id number(10) generated by default as identity not null, + parent_id number(10), + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id number(10) generated by default as identity not null, status varchar2(1), @@ -194,6 +216,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null; +create index ix_drp_mn_drp_rf_mny_drp_mn on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drp_mn_drp_rf_mny_drp_mn foreign key (drop_main_id) references drop_main (id); + +create index ix_drp_mn_drp_rf_mny_dr_d70vl on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drp_mn_drp_rf_mny_dr_joeslj foreign key (drop_ref_many_id) references drop_ref_many (id); + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id); + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.1.sql index f78c04b78..cac7e177a 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.1.sql @@ -52,6 +52,9 @@ exception when expected_error then null; end; $$; +alter table drop_main_drop_ref_many drop constraint fk_drp_mn_drp_rf_mny_drp_mn; +alter table drop_main_drop_ref_many drop constraint fk_drp_mn_drp_rf_mny_dr_joeslj; +alter table drop_ref_one drop constraint fk_drop_ref_one_parent_id; drop index ix_migtest_e_basic_indextest1; drop index ix_migtest_e_basic_indextest5; drop index ix_migtest_quoted_status1; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.2__dropsFor_1.1.sql index e3b0dbb96..649b7ea47 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.2__dropsFor_1.1.sql @@ -7,6 +7,40 @@ alter table migtest_e_basic drop column eref_id; alter table migtest_e_history2 drop column obsolete_string1; alter table migtest_e_history2 drop column obsolete_string2; -- apply post alter +drop table drop_main cascade constraints purge; +delimiter $$ +declare + expected_error exception; + pragma exception_init(expected_error, -2289); +begin + execute immediate 'drop sequence drop_main_seq'; +exception + when expected_error then null; +end; +$$; +drop table drop_main_drop_ref_many cascade constraints purge; +drop table drop_ref_many cascade constraints purge; +delimiter $$ +declare + expected_error exception; + pragma exception_init(expected_error, -2289); +begin + execute immediate 'drop sequence drop_ref_many_seq'; +exception + when expected_error then null; +end; +$$; +drop table drop_ref_one cascade constraints purge; +delimiter $$ +declare + expected_error exception; + pragma exception_init(expected_error, -2289); +begin + execute immediate 'drop sequence drop_ref_one_seq'; +exception + when expected_error then null; +end; +$$; drop table "migtest_QuOtEd" cascade constraints purge; drop table migtest_e_ref cascade constraints purge; delimiter $$ diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.3.sql index ada955aab..ad4d6de61 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.3.sql @@ -86,6 +86,11 @@ exception when expected_error then null; end; $$; +alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_mgtst_mtm_c_mgtst_mt_93awga; +alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_mgtst_mtm_c_mgtst_mt_93awgk; +alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_mgtst_mtm_m_mgtst_mt_ggi34k; +alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_mgtst_mtm_m_mgtst_mt_ggi34a; +alter table migtest_mtm_m_phone_numbers drop constraint fk_mgtst_mtm_m_phn_nmbr_s8neid; drop index ix_migtest_e_basic_indextest3; drop index ix_migtest_e_basic_indextest6; drop index ix_table_textfield2; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/idx_oracle.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/idx_oracle.migrations index 160b8b601..3d21e9158 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/idx_oracle.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/idx_oracle.migrations @@ -1,7 +1,7 @@ -1757923548, 1.0__initial.sql -740264587, 1.1.sql -930172034, 1.2__dropsFor_1.1.sql --1896525025, 1.3.sql +-126940583, 1.0__initial.sql +1459805204, 1.1.sql +1164021503, 1.2__dropsFor_1.1.sql +1644022208, 1.3.sql 2037899598, 1.4__dropsFor_1.3.sql 1357801733, R__oracle_only_views.sql 561281075, R__order_views.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.0__initial.sql index bfbc238c4..3d4518972 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.0__initial.sql @@ -62,6 +62,31 @@ create table migtest_fk_set_null ( ); create sequence migtest_fk_set_null_seq; +create table drop_main ( + id number(10) not null, + constraint pk_drop_main primary key (id) +); +create sequence drop_main_seq; + +create table drop_main_drop_ref_many ( + drop_main_id number(10) not null, + drop_ref_many_id number(10) not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id number(10) not null, + constraint pk_drop_ref_many primary key (id) +); +create sequence drop_ref_many_seq; + +create table drop_ref_one ( + id number(10) not null, + parent_id number(10), + constraint pk_drop_ref_one primary key (id) +); +create sequence drop_ref_one_seq; + create table migtest_e_basic ( id number(10) not null, status varchar2(1), @@ -216,6 +241,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null; +create index ix_drp_mn_drp_rf_mny_drp_mn on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drp_mn_drp_rf_mny_drp_mn foreign key (drop_main_id) references drop_main (id); + +create index ix_drp_mn_drp_rf_mny_dr_d70vl on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drp_mn_drp_rf_mny_dr_joeslj foreign key (drop_ref_many_id) references drop_ref_many (id); + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id); + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.1.sql index 7a24eef36..64c99f494 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.1.sql @@ -52,6 +52,9 @@ exception when expected_error then null; end; $$; +alter table drop_main_drop_ref_many drop constraint fk_drp_mn_drp_rf_mny_drp_mn; +alter table drop_main_drop_ref_many drop constraint fk_drp_mn_drp_rf_mny_dr_joeslj; +alter table drop_ref_one drop constraint fk_drop_ref_one_parent_id; drop index ix_migtest_e_basic_indextest1; drop index ix_migtest_e_basic_indextest5; drop index ix_migtest_quoted_status1; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.2__dropsFor_1.1.sql index e3b0dbb96..649b7ea47 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.2__dropsFor_1.1.sql @@ -7,6 +7,40 @@ alter table migtest_e_basic drop column eref_id; alter table migtest_e_history2 drop column obsolete_string1; alter table migtest_e_history2 drop column obsolete_string2; -- apply post alter +drop table drop_main cascade constraints purge; +delimiter $$ +declare + expected_error exception; + pragma exception_init(expected_error, -2289); +begin + execute immediate 'drop sequence drop_main_seq'; +exception + when expected_error then null; +end; +$$; +drop table drop_main_drop_ref_many cascade constraints purge; +drop table drop_ref_many cascade constraints purge; +delimiter $$ +declare + expected_error exception; + pragma exception_init(expected_error, -2289); +begin + execute immediate 'drop sequence drop_ref_many_seq'; +exception + when expected_error then null; +end; +$$; +drop table drop_ref_one cascade constraints purge; +delimiter $$ +declare + expected_error exception; + pragma exception_init(expected_error, -2289); +begin + execute immediate 'drop sequence drop_ref_one_seq'; +exception + when expected_error then null; +end; +$$; drop table "migtest_QuOtEd" cascade constraints purge; drop table migtest_e_ref cascade constraints purge; delimiter $$ diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.3.sql index 60e60243b..20a6509e7 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.3.sql @@ -86,6 +86,11 @@ exception when expected_error then null; end; $$; +alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_mgtst_mtm_c_mgtst_mt_93awga; +alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_mgtst_mtm_c_mgtst_mt_93awgk; +alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_mgtst_mtm_m_mgtst_mt_ggi34k; +alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_mgtst_mtm_m_mgtst_mt_ggi34a; +alter table migtest_mtm_m_phone_numbers drop constraint fk_mgtst_mtm_m_phn_nmbr_s8neid; drop index ix_migtest_e_basic_indextest3; drop index ix_migtest_e_basic_indextest6; drop index ix_table_textfield2; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/idx_oracle.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/idx_oracle.migrations index 3095da37b..c33c3b049 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/idx_oracle.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/idx_oracle.migrations @@ -1,7 +1,7 @@ --1422254768, 1.0__initial.sql --123689547, 1.1.sql -930172034, 1.2__dropsFor_1.1.sql -1967473644, 1.3.sql +21261569, 1.0__initial.sql +-1938703172, 1.1.sql +1164021503, 1.2__dropsFor_1.1.sql +1673954355, 1.3.sql 2037899598, 1.4__dropsFor_1.3.sql 1357801733, R__oracle_only_views.sql 561281075, R__order_views.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.0__initial.sql index 766e79bca..5ad40246f 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer generated by default as identity not null, description_file bytea, @@ -352,6 +374,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.1.sql index 4bdf82afc..c8273e6e4 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.1.sql @@ -7,6 +7,9 @@ alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2 alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table if exists drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_main; +alter table if exists drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_ref_many; +alter table if exists drop_ref_one drop constraint if exists fk_drop_ref_one_parent_id; drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.2__dropsFor_1.1.sql index 7e6c96228..034b33908 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.2__dropsFor_1.1.sql @@ -37,6 +37,13 @@ create trigger migtest_e_history2_history_upd before update or delete on migtest_e_history2 for each row execute procedure migtest_e_history2_history_version(); +drop table if exists drop_main cascade; +drop sequence if exists drop_main_seq; +drop table if exists drop_main_drop_ref_many cascade; +drop table if exists drop_ref_many cascade; +drop sequence if exists drop_ref_many_seq; +drop table if exists drop_ref_one cascade; +drop sequence if exists drop_ref_one_seq; drop table if exists "migtest_QuOtEd" cascade; drop table if exists migtest_e_ref cascade; drop sequence if exists migtest_e_ref_seq; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.3.sql index e024c1aa3..e9a619dcd 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.3.sql @@ -14,6 +14,11 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_name; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table if exists migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +alter table if exists migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +alter table if exists migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +alter table if exists migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +alter table if exists migtest_mtm_m_phone_numbers drop constraint if exists fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; drop index if exists ix_migtest_e_basic_indextest3; drop index if exists ix_migtest_e_basic_indextest6; drop index if exists ix_table_textfield2; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/idx_postgres.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/idx_postgres.migrations index 06ebb0b61..59e6a24ce 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/idx_postgres.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/idx_postgres.migrations @@ -1,7 +1,7 @@ --769462329, 1.0__initial.sql -409812555, 1.1.sql --261111052, 1.2__dropsFor_1.1.sql -1214144459, 1.3.sql +-73982981, 1.0__initial.sql +-1076179036, 1.1.sql +274267648, 1.2__dropsFor_1.1.sql +-634032267, 1.3.sql -709144111, 1.4__dropsFor_1.3.sql 783227075, R__multi_comments.sql 561281075, R__order_views.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.0__initial.sql index 21fa13691..0f344cdc2 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id serial not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id serial not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id serial not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id serial not null, description_file bytea, @@ -352,6 +374,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.1.sql index 4cf767c51..5cc39012b 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.1.sql @@ -7,6 +7,9 @@ alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2 alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table if exists drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_main; +alter table if exists drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_ref_many; +alter table if exists drop_ref_one drop constraint if exists fk_drop_ref_one_parent_id; drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.2__dropsFor_1.1.sql index 7e6c96228..034b33908 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.2__dropsFor_1.1.sql @@ -37,6 +37,13 @@ create trigger migtest_e_history2_history_upd before update or delete on migtest_e_history2 for each row execute procedure migtest_e_history2_history_version(); +drop table if exists drop_main cascade; +drop sequence if exists drop_main_seq; +drop table if exists drop_main_drop_ref_many cascade; +drop table if exists drop_ref_many cascade; +drop sequence if exists drop_ref_many_seq; +drop table if exists drop_ref_one cascade; +drop sequence if exists drop_ref_one_seq; drop table if exists "migtest_QuOtEd" cascade; drop table if exists migtest_e_ref cascade; drop sequence if exists migtest_e_ref_seq; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.3.sql index eba9fb564..5b92e11b8 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.3.sql @@ -14,6 +14,11 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_name; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table if exists migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +alter table if exists migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +alter table if exists migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +alter table if exists migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +alter table if exists migtest_mtm_m_phone_numbers drop constraint if exists fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; drop index if exists ix_migtest_e_basic_indextest3; drop index if exists ix_migtest_e_basic_indextest6; drop index if exists ix_table_textfield2; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/idx_postgres.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/idx_postgres.migrations index 5136723e3..e64bb01b0 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/idx_postgres.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/idx_postgres.migrations @@ -1,7 +1,7 @@ --309942302, 1.0__initial.sql -2116598611, 1.1.sql --261111052, 1.2__dropsFor_1.1.sql --388526579, 1.3.sql +-1033742102, 1.0__initial.sql +-1861202915, 1.1.sql +274267648, 1.2__dropsFor_1.1.sql +601885195, 1.3.sql -709144111, 1.4__dropsFor_1.3.sql 783227075, R__multi_comments.sql 561281075, R__order_views.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.0__initial.sql index 3d79a3500..3d95c0561 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer auto_increment not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer auto_increment not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer auto_increment not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer auto_increment not null, status varchar(1), @@ -194,6 +216,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.1.sql index f6c2af545..146b5ae71 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.1.sql @@ -7,6 +7,9 @@ alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2 alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_main; +alter table drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_ref_many; +alter table drop_ref_one drop constraint if exists fk_drop_ref_one_parent_id; drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.2__dropsFor_1.1.sql index cb6860e63..5934a713a 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.2__dropsFor_1.1.sql @@ -7,5 +7,9 @@ alter table migtest_e_basic drop column eref_id; alter table migtest_e_history2 drop column obsolete_string1; alter table migtest_e_history2 drop column obsolete_string2; -- apply post alter +drop table if exists drop_main; +drop table if exists drop_main_drop_ref_many; +drop table if exists drop_ref_many; +drop table if exists drop_ref_one; drop table if exists "migtest_QuOtEd"; drop table if exists migtest_e_ref; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.3.sql index 88a290c0f..218002613 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.3.sql @@ -14,6 +14,11 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_name; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +alter table migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +alter table migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +alter table migtest_mtm_m_phone_numbers drop constraint if exists fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; drop index if exists ix_migtest_e_basic_indextest3; drop index if exists ix_migtest_e_basic_indextest6; drop index if exists ix_table_textfield2; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/idx_sqlanywhere.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/idx_sqlanywhere.migrations index 5c3f07503..6118905bf 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/idx_sqlanywhere.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/idx_sqlanywhere.migrations @@ -1,6 +1,6 @@ --951189503, 1.0__initial.sql -128425002, 1.1.sql -688811494, 1.2__dropsFor_1.1.sql --519291959, 1.3.sql +1278110701, 1.0__initial.sql +-1462494667, 1.1.sql +-875723380, 1.2__dropsFor_1.1.sql +813275522, 1.3.sql 255653518, 1.4__dropsFor_1.3.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.0__initial.sql index bfd05a961..dbb047e57 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.0__initial.sql @@ -56,6 +56,31 @@ create table migtest_fk_set_null ( foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict ); +create table drop_main ( + id integer not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id), + foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict, + foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict +); + +create table drop_ref_many ( + id integer not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id), + foreign key (parent_id) references drop_main (id) on delete restrict on update restrict +); + create table migtest_e_basic ( id integer not null, status varchar(1), diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.1.sql index 3c93d203c..50fa3d06a 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.1.sql @@ -7,6 +7,9 @@ -- not supported: alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; -- not supported: alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; -- not supported: alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +-- not supported: alter table drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_main; +-- not supported: alter table drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_ref_many; +-- not supported: alter table drop_ref_one drop constraint if exists fk_drop_ref_one_parent_id; drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.2__dropsFor_1.1.sql index cb6860e63..5934a713a 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.2__dropsFor_1.1.sql @@ -7,5 +7,9 @@ alter table migtest_e_basic drop column eref_id; alter table migtest_e_history2 drop column obsolete_string1; alter table migtest_e_history2 drop column obsolete_string2; -- apply post alter +drop table if exists drop_main; +drop table if exists drop_main_drop_ref_many; +drop table if exists drop_ref_many; +drop table if exists drop_ref_one; drop table if exists "migtest_QuOtEd"; drop table if exists migtest_e_ref; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.3.sql index 791293355..acc706110 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.3.sql @@ -14,6 +14,11 @@ -- not supported: alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4; -- not supported: alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; -- not supported: alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +-- not supported: alter table migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +-- not supported: alter table migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +-- not supported: alter table migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +-- not supported: alter table migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +-- not supported: alter table migtest_mtm_m_phone_numbers drop constraint if exists fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; drop index if exists ix_migtest_e_basic_indextest3; drop index if exists ix_migtest_e_basic_indextest6; drop index if exists ix_table_textfield2; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/idx_sqlite.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/idx_sqlite.migrations index 6fa5eb1cb..2611138cc 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/idx_sqlite.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/idx_sqlite.migrations @@ -1,7 +1,7 @@ --1527127682, 1.0__initial.sql -1828386122, 1.1.sql -688811494, 1.2__dropsFor_1.1.sql -536935117, 1.3.sql +238997470, 1.0__initial.sql +-1940818706, 1.1.sql +-875723380, 1.2__dropsFor_1.1.sql +1218248753, 1.3.sql 255653518, 1.4__dropsFor_1.3.sql 2034589659, R__order_views_sqlite.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.0__initial.sql index b57f44881..d00821f76 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer identity(1,1) not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer identity(1,1) not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer identity(1,1) not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer identity(1,1) not null, status varchar(1), @@ -224,6 +246,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id); + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id); + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id); + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.1.sql index 015546583..b3d919e50 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.1.sql @@ -9,6 +9,9 @@ IF OBJECT_ID('uq_migtest_e_basic_indextest2', 'UQ') IS NOT NULL alter table migt IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_indextest6') drop index uq_migtest_e_basic_indextest6 ON migtest_e_basic; IF OBJECT_ID('uq_migtest_e_basic_indextest6', 'UQ') IS NOT NULL alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; IF OBJECT_ID('ck_migtest_e_enum_test_status', 'C') IS NOT NULL alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status; +IF OBJECT_ID('fk_drop_main_drop_ref_many_drop_main', 'F') IS NOT NULL alter table drop_main_drop_ref_many drop constraint fk_drop_main_drop_ref_many_drop_main; +IF OBJECT_ID('fk_drop_main_drop_ref_many_drop_ref_many', 'F') IS NOT NULL alter table drop_main_drop_ref_many drop constraint fk_drop_main_drop_ref_many_drop_ref_many; +IF OBJECT_ID('fk_drop_ref_one_parent_id', 'F') IS NOT NULL alter table drop_ref_one drop constraint fk_drop_ref_one_parent_id; IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest1') drop index ix_migtest_e_basic_indextest1 ON migtest_e_basic; IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest5') drop index ix_migtest_e_basic_indextest5 ON migtest_e_basic; IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('"migtest_QuOtEd"','U') AND name = 'ix_migtest_quoted_status1') drop index ix_migtest_quoted_status1 ON "migtest_QuOtEd"; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.2__dropsFor_1.1.sql index e37f34d7c..12dd0f8e0 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.2__dropsFor_1.1.sql @@ -11,6 +11,13 @@ EXEC usp_ebean_drop_column migtest_e_basic, eref_id; EXEC usp_ebean_drop_column migtest_e_history2, obsolete_string1; EXEC usp_ebean_drop_column migtest_e_history2, obsolete_string2; -- apply post alter +IF OBJECT_ID('drop_main', 'U') IS NOT NULL drop table drop_main; +IF OBJECT_ID('drop_main_seq', 'SO') IS NOT NULL drop sequence drop_main_seq; +IF OBJECT_ID('drop_main_drop_ref_many', 'U') IS NOT NULL drop table drop_main_drop_ref_many; +IF OBJECT_ID('drop_ref_many', 'U') IS NOT NULL drop table drop_ref_many; +IF OBJECT_ID('drop_ref_many_seq', 'SO') IS NOT NULL drop sequence drop_ref_many_seq; +IF OBJECT_ID('drop_ref_one', 'U') IS NOT NULL drop table drop_ref_one; +IF OBJECT_ID('drop_ref_one_seq', 'SO') IS NOT NULL drop sequence drop_ref_one_seq; IF OBJECT_ID('"migtest_QuOtEd"', 'U') IS NOT NULL drop table "migtest_QuOtEd"; IF OBJECT_ID('migtest_e_ref', 'U') IS NOT NULL drop table migtest_e_ref; IF OBJECT_ID('migtest_e_ref_seq', 'SO') IS NOT NULL drop sequence migtest_e_ref_seq; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.3.sql index cdbfa5810..66c23e764 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.3.sql @@ -19,6 +19,11 @@ IF OBJECT_ID('uq_migtest_e_basic_indextest4', 'UQ') IS NOT NULL alter table migt IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_indextest5') drop index uq_migtest_e_basic_indextest5 ON migtest_e_basic; IF OBJECT_ID('uq_migtest_e_basic_indextest5', 'UQ') IS NOT NULL alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; IF OBJECT_ID('ck_migtest_e_enum_test_status', 'C') IS NOT NULL alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status; +IF OBJECT_ID('fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c', 'F') IS NOT NULL alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +IF OBJECT_ID('fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m', 'F') IS NOT NULL alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +IF OBJECT_ID('fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m', 'F') IS NOT NULL alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +IF OBJECT_ID('fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c', 'F') IS NOT NULL alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +IF OBJECT_ID('fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id', 'F') IS NOT NULL alter table migtest_mtm_m_phone_numbers drop constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest3') drop index ix_migtest_e_basic_indextest3 ON migtest_e_basic; IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest6') drop index ix_migtest_e_basic_indextest6 ON migtest_e_basic; IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('"table"','U') AND name = 'ix_table_textfield2') drop index ix_table_textfield2 ON "table"; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/idx_sqlserver.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/idx_sqlserver.migrations index fb9b56a17..708be73b6 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/idx_sqlserver.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/idx_sqlserver.migrations @@ -1,8 +1,8 @@ 891357544, I__create_procs.sql -380683504, 1.0__initial.sql -1291465909, 1.1.sql --1431095657, 1.2__dropsFor_1.1.sql -1335479744, 1.3.sql +-1556604899, 1.0__initial.sql +359145725, 1.1.sql +-599071889, 1.2__dropsFor_1.1.sql +-1831804381, 1.3.sql -628940135, 1.4__dropsFor_1.3.sql 1607822082, R__order_views_mssql.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.0__initial.sql index e241e2ea6..de2ce1a93 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.0__initial.sql @@ -62,6 +62,31 @@ create table migtest_fk_set_null ( ); create sequence migtest_fk_set_null_seq as bigint start with 1; +create table drop_main ( + id integer not null, + constraint pk_drop_main primary key (id) +); +create sequence drop_main_seq as bigint start with 1; + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer not null, + constraint pk_drop_ref_many primary key (id) +); +create sequence drop_ref_many_seq as bigint start with 1; + +create table drop_ref_one ( + id integer not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); +create sequence drop_ref_one_seq as bigint start with 1; + create table migtest_e_basic ( id integer not null, status nvarchar(1), @@ -246,6 +271,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id); + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id); + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id); + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id); diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.1.sql index 55dab5ea4..b306ec871 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.1.sql @@ -9,6 +9,9 @@ IF OBJECT_ID('uq_migtest_e_basic_indextest2', 'UQ') IS NOT NULL alter table migt IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_indextest6') drop index uq_migtest_e_basic_indextest6 ON migtest_e_basic; IF OBJECT_ID('uq_migtest_e_basic_indextest6', 'UQ') IS NOT NULL alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; IF OBJECT_ID('ck_migtest_e_enum_test_status', 'C') IS NOT NULL alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status; +IF OBJECT_ID('fk_drop_main_drop_ref_many_drop_main', 'F') IS NOT NULL alter table drop_main_drop_ref_many drop constraint fk_drop_main_drop_ref_many_drop_main; +IF OBJECT_ID('fk_drop_main_drop_ref_many_drop_ref_many', 'F') IS NOT NULL alter table drop_main_drop_ref_many drop constraint fk_drop_main_drop_ref_many_drop_ref_many; +IF OBJECT_ID('fk_drop_ref_one_parent_id', 'F') IS NOT NULL alter table drop_ref_one drop constraint fk_drop_ref_one_parent_id; IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest1') drop index ix_migtest_e_basic_indextest1 ON migtest_e_basic; IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest5') drop index ix_migtest_e_basic_indextest5 ON migtest_e_basic; IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('"migtest_QuOtEd"','U') AND name = 'ix_migtest_quoted_status1') drop index ix_migtest_quoted_status1 ON "migtest_QuOtEd"; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.2__dropsFor_1.1.sql index e37f34d7c..12dd0f8e0 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.2__dropsFor_1.1.sql @@ -11,6 +11,13 @@ EXEC usp_ebean_drop_column migtest_e_basic, eref_id; EXEC usp_ebean_drop_column migtest_e_history2, obsolete_string1; EXEC usp_ebean_drop_column migtest_e_history2, obsolete_string2; -- apply post alter +IF OBJECT_ID('drop_main', 'U') IS NOT NULL drop table drop_main; +IF OBJECT_ID('drop_main_seq', 'SO') IS NOT NULL drop sequence drop_main_seq; +IF OBJECT_ID('drop_main_drop_ref_many', 'U') IS NOT NULL drop table drop_main_drop_ref_many; +IF OBJECT_ID('drop_ref_many', 'U') IS NOT NULL drop table drop_ref_many; +IF OBJECT_ID('drop_ref_many_seq', 'SO') IS NOT NULL drop sequence drop_ref_many_seq; +IF OBJECT_ID('drop_ref_one', 'U') IS NOT NULL drop table drop_ref_one; +IF OBJECT_ID('drop_ref_one_seq', 'SO') IS NOT NULL drop sequence drop_ref_one_seq; IF OBJECT_ID('"migtest_QuOtEd"', 'U') IS NOT NULL drop table "migtest_QuOtEd"; IF OBJECT_ID('migtest_e_ref', 'U') IS NOT NULL drop table migtest_e_ref; IF OBJECT_ID('migtest_e_ref_seq', 'SO') IS NOT NULL drop sequence migtest_e_ref_seq; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.3.sql index 860097c2e..a48483a2b 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.3.sql @@ -19,6 +19,11 @@ IF OBJECT_ID('uq_migtest_e_basic_indextest4', 'UQ') IS NOT NULL alter table migt IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'uq_migtest_e_basic_indextest5') drop index uq_migtest_e_basic_indextest5 ON migtest_e_basic; IF OBJECT_ID('uq_migtest_e_basic_indextest5', 'UQ') IS NOT NULL alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; IF OBJECT_ID('ck_migtest_e_enum_test_status', 'C') IS NOT NULL alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status; +IF OBJECT_ID('fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c', 'F') IS NOT NULL alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +IF OBJECT_ID('fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m', 'F') IS NOT NULL alter table migtest_mtm_c_migtest_mtm_m drop constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +IF OBJECT_ID('fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m', 'F') IS NOT NULL alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +IF OBJECT_ID('fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c', 'F') IS NOT NULL alter table migtest_mtm_m_migtest_mtm_c drop constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +IF OBJECT_ID('fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id', 'F') IS NOT NULL alter table migtest_mtm_m_phone_numbers drop constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest3') drop index ix_migtest_e_basic_indextest3 ON migtest_e_basic; IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest6') drop index ix_migtest_e_basic_indextest6 ON migtest_e_basic; IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('"table"','U') AND name = 'ix_table_textfield2') drop index ix_table_textfield2 ON "table"; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/idx_sqlserver.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/idx_sqlserver.migrations index edff6a17e..d99c1e64a 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/idx_sqlserver.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/idx_sqlserver.migrations @@ -1,8 +1,8 @@ 891357544, I__create_procs.sql -542129917, 1.0__initial.sql -837691787, 1.1.sql --1431095657, 1.2__dropsFor_1.1.sql --545642423, 1.3.sql +1994995811, 1.0__initial.sql +1778963293, 1.1.sql +-599071889, 1.2__dropsFor_1.1.sql +495243310, 1.3.sql -628940135, 1.4__dropsFor_1.3.sql 1607822082, R__order_views_mssql.sql diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.0__initial.sql index c39acd1ae..16c3fc75d 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.0__initial.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.0__initial.sql @@ -54,6 +54,28 @@ create table migtest_fk_set_null ( constraint pk_migtest_fk_set_null primary key (id) ); +create table drop_main ( + id integer generated by default as identity not null, + constraint pk_drop_main primary key (id) +); + +create table drop_main_drop_ref_many ( + drop_main_id integer not null, + drop_ref_many_id integer not null, + constraint pk_drop_main_drop_ref_many primary key (drop_main_id,drop_ref_many_id) +); + +create table drop_ref_many ( + id integer generated by default as identity not null, + constraint pk_drop_ref_many primary key (id) +); + +create table drop_ref_one ( + id integer generated by default as identity not null, + parent_id integer, + constraint pk_drop_ref_one primary key (id) +); + create table migtest_e_basic ( id integer generated by default as identity not null, status varchar(1), @@ -383,6 +405,15 @@ alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id forei create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id); alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; +create index ix_drop_main_drop_ref_many_drop_main on drop_main_drop_ref_many (drop_main_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_main foreign key (drop_main_id) references drop_main (id) on delete restrict on update restrict; + +create index ix_drop_main_drop_ref_many_drop_ref_many on drop_main_drop_ref_many (drop_ref_many_id); +alter table drop_main_drop_ref_many add constraint fk_drop_main_drop_ref_many_drop_ref_many foreign key (drop_ref_many_id) references drop_ref_many (id) on delete restrict on update restrict; + +create index ix_drop_ref_one_parent_id on drop_ref_one (parent_id); +alter table drop_ref_one add constraint fk_drop_ref_one_parent_id foreign key (parent_id) references drop_main (id) on delete restrict on update restrict; + create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id); alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.1.sql index 8e13c0a20..1714a3346 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.1.sql @@ -7,6 +7,9 @@ alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2 alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table if exists drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_main; +alter table if exists drop_main_drop_ref_many drop constraint if exists fk_drop_main_drop_ref_many_drop_ref_many; +alter table if exists drop_ref_one drop constraint if exists fk_drop_ref_one_parent_id; drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; drop index if exists ix_migtest_quoted_status1; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.2__dropsFor_1.1.sql index 7e6c96228..034b33908 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.2__dropsFor_1.1.sql @@ -37,6 +37,13 @@ create trigger migtest_e_history2_history_upd before update or delete on migtest_e_history2 for each row execute procedure migtest_e_history2_history_version(); +drop table if exists drop_main cascade; +drop sequence if exists drop_main_seq; +drop table if exists drop_main_drop_ref_many cascade; +drop table if exists drop_ref_many cascade; +drop sequence if exists drop_ref_many_seq; +drop table if exists drop_ref_one cascade; +drop sequence if exists drop_ref_one_seq; drop table if exists "migtest_QuOtEd" cascade; drop table if exists migtest_e_ref cascade; drop sequence if exists migtest_e_ref_seq; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.3.sql index 8665eb808..748634b8c 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.3.sql @@ -14,6 +14,11 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_name; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4; alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; +alter table if exists migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c; +alter table if exists migtest_mtm_c_migtest_mtm_m drop constraint if exists fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m; +alter table if exists migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m; +alter table if exists migtest_mtm_m_migtest_mtm_c drop constraint if exists fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c; +alter table if exists migtest_mtm_m_phone_numbers drop constraint if exists fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id; drop index if exists ix_migtest_e_basic_indextest3; drop index if exists ix_migtest_e_basic_indextest6; drop index if exists ix_table_textfield2; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/idx_yugabyte.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/idx_yugabyte.migrations index dd232e9a8..99c68d769 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/idx_yugabyte.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/idx_yugabyte.migrations @@ -1,7 +1,7 @@ --1409672039, 1.0__initial.sql -380200367, 1.1.sql --261111052, 1.2__dropsFor_1.1.sql --2084806674, 1.3.sql +113365976, 1.0__initial.sql +637070078, 1.1.sql +274267648, 1.2__dropsFor_1.1.sql +-1383541363, 1.3.sql -709144111, 1.4__dropsFor_1.3.sql 561281075, R__order_views.sql