diff --git a/ebean-ddl-generator/src/test/resources/dbinit/mysql/1.2.sql b/ebean-ddl-generator/src/test/resources/dbinit/migrationtest-procedures/mysql/1.2.sql similarity index 100% rename from ebean-ddl-generator/src/test/resources/dbinit/mysql/1.2.sql rename to ebean-ddl-generator/src/test/resources/dbinit/migrationtest-procedures/mysql/1.2.sql diff --git a/ebean-ddl-generator/src/test/resources/dbinit/mysql/1.4.sql b/ebean-ddl-generator/src/test/resources/dbinit/mysql/1.4.sql new file mode 100644 index 000000000..299434e91 --- /dev/null +++ b/ebean-ddl-generator/src/test/resources/dbinit/mysql/1.4.sql @@ -0,0 +1,273 @@ +-- Migrationscripts for ebean unittest +-- apply changes +create table migtest_ckey_assoc ( + id integer auto_increment not null, + assoc_one varchar(255), + constraint pk_migtest_ckey_assoc primary key (id) +); + +create table migtest_ckey_detail ( + id integer auto_increment not null, + something varchar(255), + constraint pk_migtest_ckey_detail primary key (id) +); + +create table migtest_ckey_parent ( + one_key integer not null, + two_key varchar(127) not null, + name varchar(255), + version integer not null, + constraint pk_migtest_ckey_parent primary key (one_key,two_key) +); + +create table migtest_fk_cascade ( + id bigint auto_increment not null, + one_id bigint, + constraint pk_migtest_fk_cascade primary key (id) +); + +create table migtest_fk_cascade_one ( + id bigint auto_increment not null, + constraint pk_migtest_fk_cascade_one primary key (id) +); + +create table migtest_fk_none ( + id bigint auto_increment not null, + one_id bigint, + constraint pk_migtest_fk_none primary key (id) +); + +create table migtest_fk_none_via_join ( + id bigint auto_increment not null, + one_id bigint, + constraint pk_migtest_fk_none_via_join primary key (id) +); + +create table migtest_fk_one ( + id bigint auto_increment not null, + constraint pk_migtest_fk_one primary key (id) +); + +create table migtest_fk_set_null ( + id bigint auto_increment not null, + one_id bigint, + constraint pk_migtest_fk_set_null primary key (id) +); + +create table migtest_e_basic ( + id integer auto_increment not null, + status varchar(1), + status2 varchar(1) default 'N' not null, + name varchar(127), + description varchar(127), + some_date datetime(6), + old_boolean tinyint(1) default 0 not null, + old_boolean2 tinyint(1), + eref_id integer, + indextest1 varchar(127), + indextest2 varchar(127), + indextest3 varchar(127), + indextest4 varchar(127), + indextest5 varchar(127), + indextest6 varchar(127), + user_id integer default 23 not null, + constraint uq_migtest_e_basic_indextest2 unique (indextest2), + constraint uq_migtest_e_basic_indextest6 unique (indextest6), + constraint pk_migtest_e_basic primary key (id) +); + +create table migtest_e_enum ( + id integer auto_increment not null, + test_status varchar(1), + constraint pk_migtest_e_enum primary key (id) +); + +create table migtest_e_history ( + id integer auto_increment not null, + test_string bigint, + constraint pk_migtest_e_history primary key (id) +); + +create table migtest_e_history2 ( + id integer auto_increment not null, + test_string varchar(255), + obsolete_string1 varchar(255), + obsolete_string2 varchar(255), + constraint pk_migtest_e_history2 primary key (id) +); + +create table migtest_e_history3 ( + id integer auto_increment not null, + test_string varchar(255), + constraint pk_migtest_e_history3 primary key (id) +); + +create table migtest_e_history4 ( + id integer auto_increment not null, + test_number integer, + constraint pk_migtest_e_history4 primary key (id) +); + +create table migtest_e_history5 ( + id integer auto_increment not null, + test_number integer, + constraint pk_migtest_e_history5 primary key (id) +); + +create table migtest_e_history6 ( + id integer auto_increment not null, + test_number1 integer, + test_number2 integer default 7 not null, + constraint pk_migtest_e_history6 primary key (id) +); + +create table migtest_e_ref ( + id integer auto_increment not null, + name varchar(127) not null, + constraint uq_migtest_e_ref_name unique (name), + constraint pk_migtest_e_ref primary key (id) +); + +create table migtest_e_softdelete ( + id integer auto_increment not null, + test_string varchar(255), + constraint pk_migtest_e_softdelete primary key (id) +); + +create table migtest_mtm_c ( + id integer auto_increment not null, + name varchar(255), + constraint pk_migtest_mtm_c primary key (id) +); + +create table migtest_mtm_m ( + id bigint auto_increment not null, + name varchar(255), + constraint pk_migtest_mtm_m primary key (id) +); + +create table migtest_oto_child ( + id integer auto_increment not null, + name varchar(255), + constraint uq_m12_otoc72 unique (name), + constraint pk_migtest_oto_child primary key (id) +); + +create table migtest_oto_master ( + id bigint auto_increment not null, + name varchar(255), + constraint uq_migtest_oto_master_name unique (name), + constraint pk_migtest_oto_master primary key (id) +); + +create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); +create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); +create index ix_m12_otoc72 on migtest_oto_child (name); +create index ix_migtest_oto_master_name on migtest_oto_master (name); +create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id); +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; + +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_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; + +alter table migtest_e_history2 add column sys_period_start datetime(6) default now(6); +alter table migtest_e_history2 add column sys_period_end datetime(6); +create table migtest_e_history2_history( + id integer, + test_string varchar(255), + obsolete_string1 varchar(255), + obsolete_string2 varchar(255), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; + +alter table migtest_e_history3 add column sys_period_start datetime(6) default now(6); +alter table migtest_e_history3 add column sys_period_end datetime(6); +create table migtest_e_history3_history( + id integer, + test_string varchar(255), + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history; + +alter table migtest_e_history4 add column sys_period_start datetime(6) default now(6); +alter table migtest_e_history4 add column sys_period_end datetime(6); +create table migtest_e_history4_history( + id integer, + test_number integer, + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history; + +alter table migtest_e_history5 add column sys_period_start datetime(6) default now(6); +alter table migtest_e_history5 add column sys_period_end datetime(6); +create table migtest_e_history5_history( + id integer, + test_number integer, + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history; + +alter table migtest_e_history6 add column sys_period_start datetime(6) default now(6); +alter table migtest_e_history6 add column sys_period_end datetime(6); +create table migtest_e_history6_history( + id integer, + test_number1 integer, + test_number2 integer, + sys_period_start datetime(6), + sys_period_end datetime(6) +); +create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history; + +delimiter $$ +create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin + insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin + insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2); +end$$ +delimiter $$ +create trigger migtest_e_history3_history_upd before update on migtest_e_history3 for each row begin + insert into migtest_e_history3_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger migtest_e_history3_history_del before delete on migtest_e_history3 for each row begin + insert into migtest_e_history3_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string); +end$$ +delimiter $$ +create trigger migtest_e_history4_history_upd before update on migtest_e_history4 for each row begin + insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger migtest_e_history4_history_del before delete on migtest_e_history4 for each row begin + insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number); +end$$ +delimiter $$ +create trigger migtest_e_history5_history_upd before update on migtest_e_history5 for each row begin + insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger migtest_e_history5_history_del before delete on migtest_e_history5 for each row begin + insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number); +end$$ +delimiter $$ +create trigger migtest_e_history6_history_upd before update on migtest_e_history6 for each row begin + insert into migtest_e_history6_history (sys_period_start,sys_period_end,id, test_number1, test_number2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number1, OLD.test_number2); + set NEW.sys_period_start = now(6); +end$$ +delimiter $$ +create trigger migtest_e_history6_history_del before delete on migtest_e_history6 for each row begin + insert into migtest_e_history6_history (sys_period_start,sys_period_end,id, test_number1, test_number2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number1, OLD.test_number2); +end$$ diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.1.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.1.sql index 37c9d9db5..be4855727 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.1.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.1.sql @@ -17,55 +17,120 @@ create table migtest_mtm_m_migtest_mtm_c ( constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id) ); +create table migtest_mtm_m_phone_numbers ( + migtest_mtm_m_id bigint not null, + value varchar(255) not null +); + alter table migtest_ckey_detail add column one_key integer; alter table migtest_ckey_detail add column two_key varchar(127); -alter table migtest_ckey_detail add constraint fk_mgtst_ck_e1qkb5 foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict; +alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict; alter table migtest_ckey_parent add column assoc_id integer; -alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l; -alter table migtest_fk_cascade add constraint fk_mgtst_fk_65kf6l foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict; -alter table migtest_fk_none add constraint fk_mgtst_fk_nn_n_d foreign key (one_id) references migtest_fk_one (id) on delete restrict; -alter table migtest_fk_none_via_join add constraint fk_mgtst_fk_9tknzj foreign key (one_id) references migtest_fk_one (id) on delete restrict; -alter table migtest_fk_set_null drop constraint fk_mgtst_fk_wicx8x; -alter table migtest_fk_set_null add constraint fk_mgtst_fk_wicx8x foreign key (one_id) references migtest_fk_one (id) on delete restrict; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_CASCADE_ONE_ID' and tabname = 'MIGTEST_FK_CASCADE') then + prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id'; + execute stmt; +end if; +end$$; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict; +alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict; +alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_SET_NULL_ONE_ID' and tabname = 'MIGTEST_FK_SET_NULL') then + prepare stmt from 'alter table migtest_fk_set_null drop constraint fk_migtest_fk_set_null_one_id'; + execute stmt; +end if; +end$$; +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 restrict; update migtest_e_basic set status = 'A' where status is null; -alter table migtest_e_basic drop constraint ck_mgtst__bsc_stts; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS' and tabname = 'MIGTEST_E_BASIC') then + prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status'; + execute stmt; +end if; +end$$; alter table migtest_e_basic alter column status set default 'A'; alter table migtest_e_basic alter column status set not null; -alter table migtest_e_basic add constraint ck_mgtst__bsc_stts check ( status in ('N','A','I','?')); -alter table migtest_e_basic drop constraint ck_mgtst__b_z543fg; +alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')); +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS2' and tabname = 'MIGTEST_E_BASIC') then + prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2'; + execute stmt; +end if; +end$$; alter table migtest_e_basic alter column status2 set data type varchar(127); alter table migtest_e_basic alter column status2 drop default; alter table migtest_e_basic alter column status2 drop not null; --- rename all collisions; +call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #1 */; +-- db2 does not support parial null indices :( - so we have to clean; +update migtest_e_basic set status = 'N' where id = 1; create unique index uq_migtest_e_basic_description on migtest_e_basic(description) exclude null keys; insert into migtest_e_user (id) select distinct user_id from migtest_e_basic; -alter table migtest_e_basic add constraint fk_mgtst__bsc_sr_d foreign key (user_id) references migtest_e_user (id) on delete restrict; +alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict; alter table migtest_e_basic alter column user_id drop not null; alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null; alter table migtest_e_basic add column new_boolean_field boolean default true not null; +call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #2 */; update migtest_e_basic set new_boolean_field = old_boolean; alter table migtest_e_basic add column new_boolean_field2 boolean default true not null; alter table migtest_e_basic add column progress integer default 0 not null; -alter table migtest_e_basic add constraint ck_mgtst__b_l39g41 check ( progress in (0,1,2)); +alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)); alter table migtest_e_basic add column new_integer integer default 42 not null; -alter table migtest_e_basic drop constraint uq_mgtst__b_4aybzy; -alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc02; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_INDEXTEST2' and tabname = 'MIGTEST_E_BASIC') then + prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2'; + execute stmt; +end if; +end$$ +delimiter $$ +begin +if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_INDEXTEST2') then + prepare stmt from 'drop index uq_migtest_e_basic_indextest2'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_INDEXTEST6' and tabname = 'MIGTEST_E_BASIC') then + prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6'; + execute stmt; +end if; +end$$ +delimiter $$ +begin +if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_INDEXTEST6') then + prepare stmt from 'drop index uq_migtest_e_basic_indextest6'; + execute stmt; +end if; +end$$; create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) exclude null keys; create unique index uq_migtest_e_basic_name on migtest_e_basic(name) exclude null keys; create unique index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) exclude null keys; create unique index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) exclude null keys; -alter table migtest_e_enum drop constraint ck_mgtst__n_773sok; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_ENUM_TEST_STATUS' and tabname = 'MIGTEST_E_ENUM') then + prepare stmt from 'alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status'; + execute stmt; +end if; +end$$; comment on column migtest_e_history.test_string is 'Column altered to long now'; alter table migtest_e_history alter column test_string set data type bigint; comment on table migtest_e_history is 'We have history now'; +call sysproc.admin_cmd('reorg table migtest_e_history') /* reorg #3 */; -- NOTE: table has @History - special migration may be necessary update migtest_e_history2 set test_string = 'unknown' where test_string is null; alter table migtest_e_history2 alter column test_string set default 'unknown'; @@ -78,6 +143,8 @@ alter table migtest_e_history4 alter column test_number set data type bigint; alter table migtest_e_history5 add column test_boolean boolean default false not null; +call sysproc.admin_cmd('reorg table migtest_e_history2') /* reorg #4 */; +call sysproc.admin_cmd('reorg table migtest_e_history4') /* reorg #5 */; -- NOTE: table has @History - special migration may be necessary update migtest_e_history6 set test_number1 = 42 where test_number1 is null; alter table migtest_e_history6 alter column test_number1 set default 42; @@ -87,24 +154,40 @@ alter table migtest_e_softdelete add column deleted boolean default false not nu alter table migtest_oto_child add column master_id bigint; -create index ix_mgtst__b_eu8css on migtest_e_basic (indextest3); -create index ix_mgtst__b_eu8csv on migtest_e_basic (indextest6); -drop index ix_mgtst__b_eu8csq; -drop index ix_mgtst__b_eu8csu; -create index ix_mgtst_mt_3ug4ok on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); -alter table migtest_mtm_c_migtest_mtm_m add constraint fk_mgtst_mt_93awga foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict; +call sysproc.admin_cmd('reorg table migtest_e_history6') /* reorg #6 */; +create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3); +create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6); +delimiter $$ +begin +if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST1') then + prepare stmt from 'drop index ix_migtest_e_basic_indextest1'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST5') then + prepare stmt from 'drop index ix_migtest_e_basic_indextest5'; + execute stmt; +end if; +end$$; +create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); +alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict; -create index ix_mgtst_mt_3ug4ou on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id); -alter table migtest_mtm_c_migtest_mtm_m add constraint fk_mgtst_mt_93awgk foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict; +create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id); +alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict; -create index ix_mgtst_mt_b7nbcu on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id); -alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mt_ggi34k foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict; +create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id); +alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict; -create index ix_mgtst_mt_b7nbck on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id); -alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mt_ggi34a foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict; +create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id); +alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict; -create index ix_mgtst_ck_x45o21 on migtest_ckey_parent (assoc_id); -alter table migtest_ckey_parent add constraint fk_mgtst_ck_da00mr foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict; +create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id); +alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict; -alter table migtest_oto_child add constraint fk_mgtst_t__csyl38 foreign key (master_id) references migtest_oto_master (id) on delete restrict; +create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id); +alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict; + +alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.3.sql index ab2148795..4b5fdcf13 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.3.sql @@ -5,44 +5,166 @@ create table migtest_e_ref ( name varchar(127) not null, constraint pk_migtest_e_ref primary key (id) ); -alter table migtest_e_ref add constraint uq_mgtst__rf_nm unique (name); +alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name); -alter table migtest_ckey_detail drop constraint fk_mgtst_ck_e1qkb5; -alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l; -alter table migtest_fk_cascade add constraint fk_mgtst_fk_65kf6l foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade; -alter table migtest_fk_none drop constraint fk_mgtst_fk_nn_n_d; -alter table migtest_fk_none_via_join drop constraint fk_mgtst_fk_9tknzj; -alter table migtest_fk_set_null drop constraint fk_mgtst_fk_wicx8x; -alter table migtest_fk_set_null add constraint fk_mgtst_fk_wicx8x foreign key (one_id) references migtest_fk_one (id) on delete set null; -alter table migtest_e_basic drop constraint ck_mgtst__bsc_stts; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_CKEY_DETAIL_PARENT' and tabname = 'MIGTEST_CKEY_DETAIL') then + prepare stmt from 'alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_CASCADE_ONE_ID' and tabname = 'MIGTEST_FK_CASCADE') then + prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id'; + execute stmt; +end if; +end$$; +alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_NONE_ONE_ID' and tabname = 'MIGTEST_FK_NONE') then + prepare stmt from 'alter table migtest_fk_none drop constraint fk_migtest_fk_none_one_id'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_NONE_VIA_JOIN_ONE_ID' and tabname = 'MIGTEST_FK_NONE_VIA_JOIN') then + prepare stmt from 'alter table migtest_fk_none_via_join drop constraint fk_migtest_fk_none_via_join_one_id'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_SET_NULL_ONE_ID' and tabname = 'MIGTEST_FK_SET_NULL') then + prepare stmt from 'alter table migtest_fk_set_null drop constraint fk_migtest_fk_set_null_one_id'; + execute stmt; +end if; +end$$; +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; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS' and tabname = 'MIGTEST_E_BASIC') then + prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status'; + execute stmt; +end if; +end$$; alter table migtest_e_basic alter column status drop default; alter table migtest_e_basic alter column status drop not null; -alter table migtest_e_basic add constraint ck_mgtst__bsc_stts check ( status in ('N','A','I')); +alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I')); +call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #1 */; update migtest_e_basic set status2 = 'N' where status2 is null; -alter table migtest_e_basic drop constraint ck_mgtst__b_z543fg; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS2' and tabname = 'MIGTEST_E_BASIC') then + prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2'; + execute stmt; +end if; +end$$; alter table migtest_e_basic alter column status2 set data type varchar(1); alter table migtest_e_basic alter column status2 set default 'N'; alter table migtest_e_basic alter column status2 set not null; -alter table migtest_e_basic add constraint ck_mgtst__b_z543fg check ( status2 in ('N','A','I')); -alter table migtest_e_basic drop constraint uq_mgtst__b_vs45xo; +alter table migtest_e_basic add constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')); +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_DESCRIPTION' and tabname = 'MIGTEST_E_BASIC') then + prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_description'; + execute stmt; +end if; +end$$ +delimiter $$ +begin +if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_DESCRIPTION') then + prepare stmt from 'drop index uq_migtest_e_basic_description'; + execute stmt; +end if; +end$$; +call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #2 */; update migtest_e_basic set user_id = 23 where user_id is null; -alter table migtest_e_basic drop constraint fk_mgtst__bsc_sr_d; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_E_BASIC_USER_ID' and tabname = 'MIGTEST_E_BASIC') then + prepare stmt from 'alter table migtest_e_basic drop constraint fk_migtest_e_basic_user_id'; + execute stmt; +end if; +end$$; alter table migtest_e_basic alter column user_id set default 23; alter table migtest_e_basic alter column user_id set not null; alter table migtest_e_basic add column old_boolean boolean default false not null; alter table migtest_e_basic add column old_boolean2 boolean; alter table migtest_e_basic add column eref_id integer; -alter table migtest_e_basic drop constraint uq_mgtst__b_ucfcne; -alter table migtest_e_basic drop constraint uq_mgtst__bsc_nm; -alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc00; -alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc01; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_STATUS_INDEXTEST1' and tabname = 'MIGTEST_E_BASIC') then + prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1'; + execute stmt; +end if; +end$$ +delimiter $$ +begin +if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_STATUS_INDEXTEST1') then + prepare stmt from 'drop index uq_migtest_e_basic_status_indextest1'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_NAME' and tabname = 'MIGTEST_E_BASIC') then + prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_name'; + execute stmt; +end if; +end$$ +delimiter $$ +begin +if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_NAME') then + prepare stmt from 'drop index uq_migtest_e_basic_name'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_INDEXTEST4' and tabname = 'MIGTEST_E_BASIC') then + prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4'; + execute stmt; +end if; +end$$ +delimiter $$ +begin +if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_INDEXTEST4') then + prepare stmt from 'drop index uq_migtest_e_basic_indextest4'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_INDEXTEST5' and tabname = 'MIGTEST_E_BASIC') then + prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5'; + execute stmt; +end if; +end$$ +delimiter $$ +begin +if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_INDEXTEST5') then + prepare stmt from 'drop index uq_migtest_e_basic_indextest5'; + execute stmt; +end if; +end$$; +call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #3 */; create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys; create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) exclude null keys; -alter table migtest_e_enum drop constraint ck_mgtst__n_773sok; -alter table migtest_e_enum add constraint ck_mgtst__n_773sok check ( test_status in ('N','A','I')); +delimiter $$ +begin +if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_ENUM_TEST_STATUS' and tabname = 'MIGTEST_E_ENUM') then + prepare stmt from 'alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status'; + execute stmt; +end if; +end$$; +alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')); comment on column migtest_e_history.test_string is ''; comment on table migtest_e_history is ''; alter table migtest_e_history2 alter column test_string drop default; @@ -54,14 +176,30 @@ alter table migtest_e_history4 alter column test_number set data type integer; alter table migtest_e_history6 alter column test_number1 drop default; alter table migtest_e_history6 alter column test_number1 drop not null; +call sysproc.admin_cmd('reorg table migtest_e_history2') /* reorg #4 */; +call sysproc.admin_cmd('reorg table migtest_e_history6') /* reorg #5 */; +call sysproc.admin_cmd('reorg table migtest_e_history4') /* reorg #6 */; -- NOTE: table has @History - special migration may be necessary update migtest_e_history6 set test_number2 = 7 where test_number2 is null; alter table migtest_e_history6 alter column test_number2 set default 7; alter table migtest_e_history6 alter column test_number2 set not null; -create index ix_mgtst__b_eu8csq on migtest_e_basic (indextest1); -create index ix_mgtst__b_eu8csu on migtest_e_basic (indextest5); -drop index ix_mgtst__b_eu8css; -drop index ix_mgtst__b_eu8csv; -create index ix_mgtst__bsc_rf_d on migtest_e_basic (eref_id); -alter table migtest_e_basic add constraint fk_mgtst__bsc_rf_d foreign key (eref_id) references migtest_e_ref (id) on delete restrict; +call sysproc.admin_cmd('reorg table migtest_e_history6') /* reorg #7 */; +create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); +create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); +delimiter $$ +begin +if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST3') then + prepare stmt from 'drop index ix_migtest_e_basic_indextest3'; + execute stmt; +end if; +end$$; +delimiter $$ +begin +if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST6') then + prepare stmt from 'drop index ix_migtest_e_basic_indextest6'; + execute stmt; +end if; +end$$; +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; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.4__dropsFor_1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.4__dropsFor_1.3.sql index 274f3b336..582d359cb 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.4__dropsFor_1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.4__dropsFor_1.3.sql @@ -38,6 +38,7 @@ end if; end$$; drop table migtest_mtm_c_migtest_mtm_m; drop table migtest_mtm_m_migtest_mtm_c; +drop table migtest_mtm_m_phone_numbers; call sysproc.admin_cmd('reorg table migtest_e_history2') /* reorg #1 */; call sysproc.admin_cmd('reorg table migtest_e_softdelete') /* reorg #2 */; call sysproc.admin_cmd('reorg table migtest_oto_child') /* reorg #3 */; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/idx_db2.migrations b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/idx_db2.migrations index b743c8e07..b1d354f3f 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/idx_db2.migrations +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/idx_db2.migrations @@ -1,6 +1,6 @@ 1580812656, 1.0__initial.sql -312838996, 1.1.sql +-2144208808, 1.1.sql 1091886546, 1.2__dropsFor_1.1.sql -1041850370, 1.3.sql -2020621716, 1.4__dropsFor_1.3.sql +1293885677, 1.4__dropsFor_1.3.sql diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.1.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.1.sql index b51d15d2e..f639a2e9b 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.1.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.1.sql @@ -23,6 +23,11 @@ create table migtest_mtm_m_migtest_mtm_c ( constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id) ); +create table migtest_mtm_m_phone_numbers ( + migtest_mtm_m_id bigint not null, + value varchar(255) not null +); + alter table migtest_ckey_detail add column one_key integer; alter table migtest_ckey_detail add column two_key varchar(127); @@ -114,6 +119,9 @@ alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_ create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id); alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; +create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id); +alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict; + create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id); alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.4__dropsFor_1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.4__dropsFor_1.3.sql index 1776f5309..6574eb2db 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.4__dropsFor_1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/1.4__dropsFor_1.3.sql @@ -46,6 +46,7 @@ drop table if exists migtest_e_user; drop sequence if exists migtest_e_user_seq; drop table if exists migtest_mtm_c_migtest_mtm_m; drop table if exists migtest_mtm_m_migtest_mtm_c; +drop table if exists migtest_mtm_m_phone_numbers; create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/idx_h2.migrations b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/idx_h2.migrations index fb21ce854..75357518c 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/idx_h2.migrations +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/h2/idx_h2.migrations @@ -1,6 +1,6 @@ -745768926, 1.0__initial.sql -39858255, 1.1.sql +1409369419, 1.1.sql 1616986842, 1.2__dropsFor_1.1.sql -1513154593, 1.3.sql -374569329, 1.4__dropsFor_1.3.sql +1549130952, 1.4__dropsFor_1.3.sql diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.1.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.1.sql index 7f92f6534..0379b11ee 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.1.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.1.sql @@ -17,6 +17,11 @@ create column table migtest_mtm_m_migtest_mtm_c ( constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id) ); +create column table migtest_mtm_m_phone_numbers ( + migtest_mtm_m_id bigint not null, + value nvarchar(255) not null +); + alter table migtest_ckey_detail add ( one_key integer); alter table migtest_ckey_detail add ( two_key nvarchar(127)); @@ -162,6 +167,9 @@ alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_ -- explicit index "ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c" for single column "migtest_mtm_c_id" of table "migtest_mtm_m_migtest_mtm_c" is not necessary; alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; +-- explicit index "ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id" for single column "migtest_mtm_m_id" of table "migtest_mtm_m_phone_numbers" is not necessary; +alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict; + -- explicit index "ix_migtest_ckey_parent_assoc_id" for single column "assoc_id" of table "migtest_ckey_parent" is not necessary; alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.4__dropsFor_1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.4__dropsFor_1.3.sql index fe5d6371f..526dc7287 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.4__dropsFor_1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/1.4__dropsFor_1.3.sql @@ -49,3 +49,4 @@ CALL usp_ebean_drop_column('migtest_oto_child', 'master_id'); drop table migtest_e_user cascade; drop table migtest_mtm_c_migtest_mtm_m cascade; drop table migtest_mtm_m_migtest_mtm_c cascade; +drop table migtest_mtm_m_phone_numbers cascade; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/idx_hana.migrations b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/idx_hana.migrations index 984c4bb50..a3feba342 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/idx_hana.migrations +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hana/idx_hana.migrations @@ -1,6 +1,6 @@ -1536923954, 1.0__initial.sql -1039838314, 1.1.sql +-1152055114, 1.1.sql 562867593, 1.2__dropsFor_1.1.sql 1566488731, 1.3.sql -1030652294, 1.4__dropsFor_1.3.sql +201970227, 1.4__dropsFor_1.3.sql diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.1.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.1.sql index cebb8b994..31569c927 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.1.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.1.sql @@ -17,6 +17,11 @@ create table migtest_mtm_m_migtest_mtm_c ( constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id) ); +create table migtest_mtm_m_phone_numbers ( + migtest_mtm_m_id bigint not null, + value varchar(255) not null +); + alter table migtest_ckey_detail add column one_key integer; alter table migtest_ckey_detail add column two_key varchar(127); @@ -103,6 +108,9 @@ alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_ create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id); alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; +create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id); +alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict; + create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id); alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.4__dropsFor_1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.4__dropsFor_1.3.sql index c613e4a5a..706cd2892 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.4__dropsFor_1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/1.4__dropsFor_1.3.sql @@ -32,3 +32,4 @@ drop table if exists migtest_e_user; drop sequence if exists migtest_e_user_seq; drop table if exists migtest_mtm_c_migtest_mtm_m; drop table if exists migtest_mtm_m_migtest_mtm_c; +drop table if exists migtest_mtm_m_phone_numbers; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/idx_hsqldb.migrations b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/idx_hsqldb.migrations index ee5e2bd41..c9d7c5c84 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/idx_hsqldb.migrations +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/hsqldb/idx_hsqldb.migrations @@ -1,6 +1,6 @@ 2097980375, 1.0__initial.sql -2086418403, 1.1.sql +-865579750, 1.1.sql -1462014216, 1.2__dropsFor_1.1.sql -2039573992, 1.3.sql -2106151405, 1.4__dropsFor_1.3.sql +-1763496614, 1.4__dropsFor_1.3.sql diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/model/1.1.model.xml b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/model/1.1.model.xml index f913814b4..cfbb7c009 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/model/1.1.model.xml +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/model/1.1.model.xml @@ -85,6 +85,10 @@ + + + + diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/model/1.3.model.xml b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/model/1.3.model.xml index 77171547d..296b101b0 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/model/1.3.model.xml +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/model/1.3.model.xml @@ -69,5 +69,6 @@ + \ No newline at end of file diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/model/1.4__dropsFor_1.3.model.xml b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/model/1.4__dropsFor_1.3.model.xml index a1cc6616a..19dce6648 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/model/1.4__dropsFor_1.3.model.xml +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/model/1.4__dropsFor_1.3.model.xml @@ -19,5 +19,6 @@ + \ No newline at end of file diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.1.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.1.sql index e3e5bf26a..16d54565f 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.1.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.1.sql @@ -23,6 +23,11 @@ create table migtest_mtm_m_migtest_mtm_c ( constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id) ); +create table migtest_mtm_m_phone_numbers ( + migtest_mtm_m_id bigint not null, + value varchar(255) not null +); + alter table migtest_ckey_detail add column one_key integer; alter table migtest_ckey_detail add column two_key varchar(127); @@ -107,6 +112,9 @@ alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_ create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id); alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; +create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id); +alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict; + create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id); alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.4__dropsFor_1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.4__dropsFor_1.3.sql index ff8fa50d0..a560bd320 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.4__dropsFor_1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/1.4__dropsFor_1.3.sql @@ -46,6 +46,7 @@ alter table migtest_oto_child drop column master_id; drop table if exists migtest_e_user; drop table if exists migtest_mtm_c_migtest_mtm_m; drop table if exists migtest_mtm_m_migtest_mtm_c; +drop table if exists migtest_mtm_m_phone_numbers; create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/idx_mysql.migrations b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/idx_mysql.migrations index 2ce271cdc..9ead8d1dd 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/idx_mysql.migrations +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql/idx_mysql.migrations @@ -1,6 +1,6 @@ 1075178692, 1.0__initial.sql -880212944, 1.1.sql +-1627573867, 1.1.sql 1029390755, 1.2__dropsFor_1.1.sql -380371830, 1.3.sql -1085680731, 1.4__dropsFor_1.3.sql +-724776884, 1.4__dropsFor_1.3.sql diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.1.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.1.sql index e3e5bf26a..16d54565f 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.1.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.1.sql @@ -23,6 +23,11 @@ create table migtest_mtm_m_migtest_mtm_c ( constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id) ); +create table migtest_mtm_m_phone_numbers ( + migtest_mtm_m_id bigint not null, + value varchar(255) not null +); + alter table migtest_ckey_detail add column one_key integer; alter table migtest_ckey_detail add column two_key varchar(127); @@ -107,6 +112,9 @@ alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_ create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id); alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; +create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id); +alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict; + create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id); alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.4__dropsFor_1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.4__dropsFor_1.3.sql index ff8fa50d0..a560bd320 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.4__dropsFor_1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/1.4__dropsFor_1.3.sql @@ -46,6 +46,7 @@ alter table migtest_oto_child drop column master_id; drop table if exists migtest_e_user; drop table if exists migtest_mtm_c_migtest_mtm_m; drop table if exists migtest_mtm_m_migtest_mtm_c; +drop table if exists migtest_mtm_m_phone_numbers; create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/idx_mysql.migrations b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/idx_mysql.migrations index 9bf86f51e..1da1a9eae 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/idx_mysql.migrations +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/mysql55/idx_mysql.migrations @@ -1,6 +1,6 @@ -1087663151, 1.0__initial.sql -880212944, 1.1.sql +-1627573867, 1.1.sql 1029390755, 1.2__dropsFor_1.1.sql -380371830, 1.3.sql -1085680731, 1.4__dropsFor_1.3.sql +-724776884, 1.4__dropsFor_1.3.sql diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.1.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.1.sql index 7e6c98a90..3a706374e 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.1.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.1.sql @@ -17,6 +17,11 @@ create table migtest_mtm_m_migtest_mtm_c ( constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id) ); +create table migtest_mtm_m_phone_numbers ( + migtest_mtm_m_id number(19) not null, + value varchar2(255) not null +); + alter table migtest_ckey_detail add one_key number(10); alter table migtest_ckey_detail add two_key varchar2(127); @@ -103,6 +108,9 @@ alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mtm_m_mgtst_mt_g create index ix_mgtst_mtm_m_mgtst_mt_b7nbck on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id); alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mtm_m_mgtst_mt_ggi34a foreign key (migtest_mtm_c_id) references migtest_mtm_c (id); +create index ix_mgtst_mtm_m_phn_nmbr_do9ma3 on migtest_mtm_m_phone_numbers (migtest_mtm_m_id); +alter table migtest_mtm_m_phone_numbers add constraint fk_mgtst_mtm_m_phn_nmbr_s8neid foreign key (migtest_mtm_m_id) references migtest_mtm_m (id); + create index ix_mgtst_cky_prnt_ssc_d on migtest_ckey_parent (assoc_id); alter table migtest_ckey_parent add constraint fk_mgtst_cky_prnt_ssc_d foreign key (assoc_id) references migtest_ckey_assoc (id); diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.4__dropsFor_1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.4__dropsFor_1.3.sql index 52c81411a..34fe0bed4 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.4__dropsFor_1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/1.4__dropsFor_1.3.sql @@ -32,3 +32,4 @@ drop table migtest_e_user cascade constraints purge; drop sequence migtest_e_user_seq; drop table migtest_mtm_c_migtest_mtm_m cascade constraints purge; drop table migtest_mtm_m_migtest_mtm_c cascade constraints purge; +drop table migtest_mtm_m_phone_numbers cascade constraints purge; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/idx_oracle.migrations b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/idx_oracle.migrations index 533b50b15..b0f9fe30f 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/idx_oracle.migrations +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/oracle/idx_oracle.migrations @@ -1,6 +1,6 @@ 1164675950, 1.0__initial.sql --1916315387, 1.1.sql +-411370666, 1.1.sql 238598298, 1.2__dropsFor_1.1.sql 483114276, 1.3.sql -1213528478, 1.4__dropsFor_1.3.sql +-629809805, 1.4__dropsFor_1.3.sql diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.1.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.1.sql index 1c0ef5385..37be77440 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.1.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.1.sql @@ -23,6 +23,11 @@ create table migtest_mtm_m_migtest_mtm_c ( constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id) ); +create table migtest_mtm_m_phone_numbers ( + migtest_mtm_m_id bigint not null, + value varchar(255) not null +); + alter table migtest_ckey_detail add column one_key integer; alter table migtest_ckey_detail add column two_key varchar(127); @@ -120,6 +125,9 @@ alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_ create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id); alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; +create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id); +alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict; + create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id); alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.4__dropsFor_1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.4__dropsFor_1.3.sql index 748ee959b..4524d4a40 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.4__dropsFor_1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/1.4__dropsFor_1.3.sql @@ -47,6 +47,7 @@ drop table if exists migtest_e_user cascade; drop sequence if exists migtest_e_user_seq; drop table if exists migtest_mtm_c_migtest_mtm_m cascade; drop table if exists migtest_mtm_m_migtest_mtm_c cascade; +drop table if exists migtest_mtm_m_phone_numbers cascade; create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/idx_postgres.migrations b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/idx_postgres.migrations index 7e74e6b50..171a8e09b 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/idx_postgres.migrations +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/postgres/idx_postgres.migrations @@ -1,6 +1,6 @@ 1329543701, 1.0__initial.sql --1877647184, 1.1.sql +1548995254, 1.1.sql -1861367028, 1.2__dropsFor_1.1.sql -1798982281, 1.3.sql -1959776888, 1.4__dropsFor_1.3.sql +-1991941691, 1.4__dropsFor_1.3.sql diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/1.1.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/1.1.sql index a762b673e..888db9989 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/1.1.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/1.1.sql @@ -21,6 +21,12 @@ create table migtest_mtm_m_migtest_mtm_c ( foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict ); +create table migtest_mtm_m_phone_numbers ( + migtest_mtm_m_id integer not null, + value varchar(255) not null, + foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict +); + alter table migtest_ckey_detail add column one_key integer; alter table migtest_ckey_detail add column two_key varchar(127); diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/1.4__dropsFor_1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/1.4__dropsFor_1.3.sql index 24e4e93ba..f45a36211 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/1.4__dropsFor_1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/1.4__dropsFor_1.3.sql @@ -31,3 +31,4 @@ alter table migtest_oto_child drop column master_id; drop table if exists migtest_e_user; drop table if exists migtest_mtm_c_migtest_mtm_m; drop table if exists migtest_mtm_m_migtest_mtm_c; +drop table if exists migtest_mtm_m_phone_numbers; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/idx_sqlite.migrations b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/idx_sqlite.migrations index 919841fde..f5be8c486 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/idx_sqlite.migrations +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlite/idx_sqlite.migrations @@ -1,6 +1,6 @@ 1429491518, 1.0__initial.sql --347121868, 1.1.sql +-1974335860, 1.1.sql 1359055889, 1.2__dropsFor_1.1.sql -1764531063, 1.3.sql --1070218324, 1.4__dropsFor_1.3.sql +-1045594368, 1.4__dropsFor_1.3.sql diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.1.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.1.sql index f8ba67fe0..9090ca711 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.1.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.1.sql @@ -18,6 +18,11 @@ create table migtest_mtm_m_migtest_mtm_c ( constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id) ); +create table migtest_mtm_m_phone_numbers ( + migtest_mtm_m_id numeric(19) not null, + value nvarchar(255) not null +); + alter table migtest_ckey_detail add one_key integer; alter table migtest_ckey_detail add two_key nvarchar(127); @@ -103,6 +108,9 @@ alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_ create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id); alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id); +create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id); +alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id); + create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id); alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id); diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.4__dropsFor_1.3.sql b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.4__dropsFor_1.3.sql index 4cc7ad30b..3f465ec78 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.4__dropsFor_1.3.sql +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/1.4__dropsFor_1.3.sql @@ -32,6 +32,7 @@ IF OBJECT_ID('migtest_e_user', 'U') IS NOT NULL drop table migtest_e_user; IF OBJECT_ID('migtest_e_user_seq', 'SO') IS NOT NULL drop sequence migtest_e_user_seq; IF OBJECT_ID('migtest_mtm_c_migtest_mtm_m', 'U') IS NOT NULL drop table migtest_mtm_c_migtest_mtm_m; IF OBJECT_ID('migtest_mtm_m_migtest_mtm_c', 'U') IS NOT NULL drop table migtest_mtm_m_migtest_mtm_c; +IF OBJECT_ID('migtest_mtm_m_phone_numbers', 'U') IS NOT NULL drop table migtest_mtm_m_phone_numbers; -- dropping history support for migtest_e_history; EXEC usp_ebean_drop_default_constraint migtest_e_history, sys_periodFrom; EXEC usp_ebean_drop_default_constraint migtest_e_history, sys_periodTo; diff --git a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/idx_sqlserver.migrations b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/idx_sqlserver.migrations index f7cd1c04a..9e3b7e650 100644 --- a/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/idx_sqlserver.migrations +++ b/ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/sqlserver17/idx_sqlserver.migrations @@ -1,7 +1,7 @@ -2122378240, I__create_procs.sql -1048913407, 1.0__initial.sql -615613536, 1.1.sql +-898063858, 1.1.sql -1805601919, 1.2__dropsFor_1.1.sql -1791137342, 1.3.sql -460536923, 1.4__dropsFor_1.3.sql +-1335541264, 1.4__dropsFor_1.3.sql