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 52fee3a2e..cc23e8881 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 @@ -159,9 +159,73 @@ create table migtest_oto_master ( constraint pk_migtest_oto_master primary key (id) ); +-- apply alter tables +alter table migtest_e_history2 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history2 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history2 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history2 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history3 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history3 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history3 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history3 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history4 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history4 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history4 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history4 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history5 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history5 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history5 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history5 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history6 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history6 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history6 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history6 add period system_time (sys_period_start,sys_period_end); -- apply post alter 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; +create table migtest_e_history2_history ( + id integer not null, + test_string varchar(255), + obsolete_string1 varchar(255), + obsolete_string2 varchar(255), + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history2 add versioning use history table migtest_e_history2_history; +create table migtest_e_history3_history ( + id integer not null, + test_string varchar(255), + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history3 add versioning use history table migtest_e_history3_history; +create table migtest_e_history4_history ( + id integer not null, + test_number integer, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history4 add versioning use history table migtest_e_history4_history; +create table migtest_e_history5_history ( + id integer not null, + test_number integer, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history5 add versioning use history table migtest_e_history5_history; +create table migtest_e_history6_history ( + id integer not null, + test_number1 integer, + test_number2 integer not null, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history6 add versioning use history table migtest_e_history6_history; alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name); -- foreign keys and indices create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id); 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 1e5338263..298982766 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 @@ -110,9 +110,14 @@ insert into migtest_e_user (id) select distinct user_id from migtest_e_basic; -- 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 drop versioning; +alter table migtest_e_history3 drop versioning; +alter table migtest_e_history4 drop versioning; +alter table migtest_e_history5 drop versioning; -- 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 drop versioning; -- apply alter tables alter table migtest_ckey_detail add column one_key integer; alter table migtest_ckey_detail add column two_key varchar(127); @@ -129,6 +134,10 @@ alter table migtest_e_basic add column new_boolean_field2 smallint default 0 def alter table migtest_e_basic add column progress integer default 0 not null; alter table migtest_e_basic add column new_integer integer default 42 not null; call sysproc.admin_cmd('reorg table migtest_e_basic'); +alter table migtest_e_history add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history add period system_time (sys_period_start,sys_period_end); alter table migtest_e_history alter column test_string set data type bigint; call sysproc.admin_cmd('reorg table migtest_e_history'); alter table migtest_e_history2 alter column test_string set default 'unknown'; @@ -137,13 +146,24 @@ alter table migtest_e_history2 add column test_string2 varchar(255); alter table migtest_e_history2 add column test_string3 varchar(255) default 'unknown' not null; alter table migtest_e_history2 add column new_column varchar(20); call sysproc.admin_cmd('reorg table migtest_e_history2'); +alter table migtest_e_history2_history alter column test_string set not null; +alter table migtest_e_history2_history add column test_string2 varchar(255); +alter table migtest_e_history2_history add column test_string3 varchar(255) default 'unknown' not null; +alter table migtest_e_history2_history add column new_column varchar(20); +call sysproc.admin_cmd('reorg table migtest_e_history2_history'); alter table migtest_e_history4 alter column test_number set data type bigint; call sysproc.admin_cmd('reorg table migtest_e_history4'); +alter table migtest_e_history4_history alter column test_number set data type bigint; +call sysproc.admin_cmd('reorg table migtest_e_history4_history'); alter table migtest_e_history5 add column test_boolean smallint default 0 default false not null; +alter table migtest_e_history5_history add column test_boolean smallint default 0 default false not null; alter table migtest_e_history6 alter column test_number1 set default 42; alter table migtest_e_history6 alter column test_number1 set not null; alter table migtest_e_history6 alter column test_number2 drop not null; call sysproc.admin_cmd('reorg table migtest_e_history6'); +alter table migtest_e_history6_history alter column test_number1 set not null; +alter table migtest_e_history6_history alter column test_number2 drop not null; +call sysproc.admin_cmd('reorg table migtest_e_history6_history'); alter table migtest_e_softdelete add column deleted smallint default 0 default false not null; alter table migtest_oto_child add column master_id bigint; -- apply post alter @@ -157,8 +177,21 @@ create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(stat 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; +create table migtest_e_history_history ( + id integer not null, + test_string bigint, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history add versioning use history table migtest_e_history_history; comment on column migtest_e_history.test_string is 'Column altered to long now'; comment on table migtest_e_history is 'We have history now'; +alter table migtest_e_history2 add versioning use history table migtest_e_history2_history; +alter table migtest_e_history3 add versioning use history table migtest_e_history3_history; +alter table migtest_e_history4 add versioning use history table migtest_e_history4_history; +alter table migtest_e_history5 add versioning use history table migtest_e_history5_history; +alter table migtest_e_history6 add versioning use history table migtest_e_history6_history; -- foreign keys and indices 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 on update restrict; 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 50f34feed..7f78aa9b3 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 @@ -1,4 +1,6 @@ -- Migrationscripts for ebean unittest +-- apply changes +alter table migtest_e_history2 drop versioning; -- apply alter tables alter table migtest_e_basic drop column description_file; alter table migtest_e_basic drop column old_boolean; @@ -8,7 +10,11 @@ call sysproc.admin_cmd('reorg table migtest_e_basic'); alter table migtest_e_history2 drop column obsolete_string1; alter table migtest_e_history2 drop column obsolete_string2; call sysproc.admin_cmd('reorg table migtest_e_history2'); +alter table migtest_e_history2_history drop column obsolete_string1; +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 migtest_e_ref; delimiter $$ begin 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 dd47fb80e..557ab8d29 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 @@ -158,6 +158,10 @@ create table migtest_e_ref ( update migtest_e_basic set status2 = 'N' where status2 is null; update migtest_e_basic set user_id = 23 where user_id is null; +alter table migtest_e_history2 drop versioning; +alter table migtest_e_history3 drop versioning; +alter table migtest_e_history4 drop versioning; +alter table migtest_e_history6 drop versioning; -- NOTE: table has @History - special migration may be necessary update migtest_e_history6 set test_number2 = 7 where test_number2 is null; @@ -178,13 +182,21 @@ alter table migtest_e_history2 alter column test_string drop default; alter table migtest_e_history2 alter column test_string drop not null; alter table migtest_e_history2 add column obsolete_string1 varchar(255); alter table migtest_e_history2 add column obsolete_string2 varchar(255); +alter table migtest_e_history2_history alter column test_string drop not null; +alter table migtest_e_history2_history add column obsolete_string1 varchar(255); +alter table migtest_e_history2_history add column obsolete_string2 varchar(255); alter table migtest_e_history4 alter column test_number set data type integer; call sysproc.admin_cmd('reorg table migtest_e_history4'); +alter table migtest_e_history4_history alter column test_number set data type integer; +call sysproc.admin_cmd('reorg table migtest_e_history4_history'); alter table migtest_e_history6 alter column test_number1 drop default; alter table migtest_e_history6 alter column test_number1 drop not 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; call sysproc.admin_cmd('reorg table migtest_e_history6'); +alter table migtest_e_history6_history alter column test_number1 drop not null; +alter table migtest_e_history6_history alter column test_number2 set not null; +call sysproc.admin_cmd('reorg table migtest_e_history6_history'); -- apply post alter alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name); alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I')); @@ -194,6 +206,10 @@ create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) 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 add versioning use history table migtest_e_history2_history; +alter table migtest_e_history3 add versioning use history table migtest_e_history3_history; +alter table migtest_e_history4 add versioning use history table migtest_e_history4_history; +alter table migtest_e_history6 add versioning use history table migtest_e_history6_history; -- foreign keys and indices 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; 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; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.4__dropsFor_1.3.sql index 98a76eaf1..5542a954f 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.4__dropsFor_1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.4__dropsFor_1.3.sql @@ -1,4 +1,9 @@ -- Migrationscripts for ebean unittest +-- apply changes +alter table migtest_e_history drop versioning; +alter table migtest_e_history drop period system_time; +alter table migtest_e_history2 drop versioning; +alter table migtest_e_history5 drop versioning; -- apply alter tables alter table migtest_ckey_detail drop column one_key; alter table migtest_ckey_detail drop column two_key; @@ -11,17 +16,30 @@ alter table migtest_e_basic drop column new_boolean_field2; alter table migtest_e_basic drop column progress; alter table migtest_e_basic drop column new_integer; call sysproc.admin_cmd('reorg table migtest_e_basic'); +alter table migtest_e_history drop column sys_period_start; +alter table migtest_e_history drop column sys_period_end; +alter table migtest_e_history drop column sys_period_txn; +call sysproc.admin_cmd('reorg table migtest_e_history'); alter table migtest_e_history2 drop column test_string2; alter table migtest_e_history2 drop column test_string3; alter table migtest_e_history2 drop column new_column; call sysproc.admin_cmd('reorg table migtest_e_history2'); +alter table migtest_e_history2_history drop column test_string2; +alter table migtest_e_history2_history drop column test_string3; +alter table migtest_e_history2_history drop column new_column; +call sysproc.admin_cmd('reorg table migtest_e_history2_history'); alter table migtest_e_history5 drop column test_boolean; call sysproc.admin_cmd('reorg table migtest_e_history5'); +alter table migtest_e_history5_history drop column test_boolean; +call sysproc.admin_cmd('reorg table migtest_e_history5_history'); alter table migtest_e_softdelete drop column deleted; call sysproc.admin_cmd('reorg table migtest_e_softdelete'); alter table migtest_oto_child drop column master_id; call sysproc.admin_cmd('reorg table migtest_oto_child'); -- apply post alter +drop table migtest_e_history_history; +alter table migtest_e_history2 add versioning use history table migtest_e_history2_history; +alter table migtest_e_history5 add versioning use history table migtest_e_history5_history; drop table migtest_e_user; delimiter $$ begin 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 286bcc203..7b05091cd 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 @@ -1004346570, 1.0__initial.sql -972719393, 1.1.sql -859277843, 1.2__dropsFor_1.1.sql --583344310, 1.3.sql -1763447809, 1.4__dropsFor_1.3.sql +-1173442860, 1.0__initial.sql +-504970252, 1.1.sql +364066694, 1.2__dropsFor_1.1.sql +-2046803765, 1.3.sql +-1199420632, 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 e9412a536..cacec3063 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 @@ -159,9 +159,73 @@ create table migtest_oto_master ( constraint pk_migtest_oto_master primary key (id) ); +-- apply alter tables +alter table migtest_e_history2 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history2 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history2 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history2 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history3 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history3 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history3 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history3 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history4 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history4 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history4 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history4 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history5 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history5 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history5 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history5 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history6 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history6 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history6 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history6 add period system_time (sys_period_start,sys_period_end); -- apply post alter create unique index uq_mgtst__b_4aybzy on migtest_e_basic(indextest2) exclude null keys; create unique index uq_mgtst__b_4ayc02 on migtest_e_basic(indextest6) exclude null keys; +create table migtest_e_history2_history ( + id integer not null, + test_string varchar(255), + obsolete_string1 varchar(255), + obsolete_string2 varchar(255), + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history2 add versioning use history table migtest_e_history2_history; +create table migtest_e_history3_history ( + id integer not null, + test_string varchar(255), + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history3 add versioning use history table migtest_e_history3_history; +create table migtest_e_history4_history ( + id integer not null, + test_number integer, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history4 add versioning use history table migtest_e_history4_history; +create table migtest_e_history5_history ( + id integer not null, + test_number integer, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history5 add versioning use history table migtest_e_history5_history; +create table migtest_e_history6_history ( + id integer not null, + test_number1 integer, + test_number2 integer not null, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history6 add versioning use history table migtest_e_history6_history; alter table migtest_e_ref add constraint uq_mgtst__rf_nm unique (name); -- foreign keys and indices create index ix_mgtst_fk_mok1xj on migtest_fk_cascade (one_id); 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 4ca572ac6..4f0ea1cf5 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 @@ -110,9 +110,14 @@ insert into migtest_e_user (id) select distinct user_id from migtest_e_basic; -- 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 drop versioning; +alter table migtest_e_history3 drop versioning; +alter table migtest_e_history4 drop versioning; +alter table migtest_e_history5 drop versioning; -- 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 drop versioning; -- apply alter tables alter table migtest_ckey_detail add column one_key integer; alter table migtest_ckey_detail add column two_key varchar(127); @@ -129,6 +134,10 @@ alter table migtest_e_basic add column new_boolean_field2 boolean default true n alter table migtest_e_basic add column progress integer default 0 not null; alter table migtest_e_basic add column new_integer integer default 42 not null; call sysproc.admin_cmd('reorg table migtest_e_basic'); +alter table migtest_e_history add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history add period system_time (sys_period_start,sys_period_end); alter table migtest_e_history alter column test_string set data type bigint; call sysproc.admin_cmd('reorg table migtest_e_history'); alter table migtest_e_history2 alter column test_string set default 'unknown'; @@ -137,13 +146,24 @@ alter table migtest_e_history2 add column test_string2 varchar(255); alter table migtest_e_history2 add column test_string3 varchar(255) default 'unknown' not null; alter table migtest_e_history2 add column new_column varchar(20); call sysproc.admin_cmd('reorg table migtest_e_history2'); +alter table migtest_e_history2_history alter column test_string set not null; +alter table migtest_e_history2_history add column test_string2 varchar(255); +alter table migtest_e_history2_history add column test_string3 varchar(255) default 'unknown' not null; +alter table migtest_e_history2_history add column new_column varchar(20); +call sysproc.admin_cmd('reorg table migtest_e_history2_history'); alter table migtest_e_history4 alter column test_number set data type bigint; call sysproc.admin_cmd('reorg table migtest_e_history4'); +alter table migtest_e_history4_history alter column test_number set data type bigint; +call sysproc.admin_cmd('reorg table migtest_e_history4_history'); alter table migtest_e_history5 add column test_boolean boolean default false not null; +alter table migtest_e_history5_history add column test_boolean boolean default false not null; alter table migtest_e_history6 alter column test_number1 set default 42; alter table migtest_e_history6 alter column test_number1 set not null; alter table migtest_e_history6 alter column test_number2 drop not null; call sysproc.admin_cmd('reorg table migtest_e_history6'); +alter table migtest_e_history6_history alter column test_number1 set not null; +alter table migtest_e_history6_history alter column test_number2 drop not null; +call sysproc.admin_cmd('reorg table migtest_e_history6_history'); alter table migtest_e_softdelete add column deleted boolean default false not null; alter table migtest_oto_child add column master_id bigint; -- apply post alter @@ -157,8 +177,21 @@ create unique index uq_mgtst__b_ucfcne on migtest_e_basic(status,indextest1) exc create unique index uq_mgtst__bsc_nm on migtest_e_basic(name) exclude null keys; create unique index uq_mgtst__b_4ayc00 on migtest_e_basic(indextest4) exclude null keys; create unique index uq_mgtst__b_4ayc01 on migtest_e_basic(indextest5) exclude null keys; +create table migtest_e_history_history ( + id integer not null, + test_string bigint, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history add versioning use history table migtest_e_history_history; comment on column migtest_e_history.test_string is 'Column altered to long now'; comment on table migtest_e_history is 'We have history now'; +alter table migtest_e_history2 add versioning use history table migtest_e_history2_history; +alter table migtest_e_history3 add versioning use history table migtest_e_history3_history; +alter table migtest_e_history4 add versioning use history table migtest_e_history4_history; +alter table migtest_e_history5 add versioning use history table migtest_e_history5_history; +alter table migtest_e_history6 add versioning use history table migtest_e_history6_history; -- foreign keys and indices 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 on update restrict; 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 50f34feed..7f78aa9b3 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 @@ -1,4 +1,6 @@ -- Migrationscripts for ebean unittest +-- apply changes +alter table migtest_e_history2 drop versioning; -- apply alter tables alter table migtest_e_basic drop column description_file; alter table migtest_e_basic drop column old_boolean; @@ -8,7 +10,11 @@ call sysproc.admin_cmd('reorg table migtest_e_basic'); alter table migtest_e_history2 drop column obsolete_string1; alter table migtest_e_history2 drop column obsolete_string2; call sysproc.admin_cmd('reorg table migtest_e_history2'); +alter table migtest_e_history2_history drop column obsolete_string1; +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 migtest_e_ref; delimiter $$ begin 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 c236a0034..4dc9a692d 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 @@ -158,6 +158,10 @@ create table migtest_e_ref ( update migtest_e_basic set status2 = 'N' where status2 is null; update migtest_e_basic set user_id = 23 where user_id is null; +alter table migtest_e_history2 drop versioning; +alter table migtest_e_history3 drop versioning; +alter table migtest_e_history4 drop versioning; +alter table migtest_e_history6 drop versioning; -- NOTE: table has @History - special migration may be necessary update migtest_e_history6 set test_number2 = 7 where test_number2 is null; @@ -178,13 +182,21 @@ alter table migtest_e_history2 alter column test_string drop default; alter table migtest_e_history2 alter column test_string drop not null; alter table migtest_e_history2 add column obsolete_string1 varchar(255); alter table migtest_e_history2 add column obsolete_string2 varchar(255); +alter table migtest_e_history2_history alter column test_string drop not null; +alter table migtest_e_history2_history add column obsolete_string1 varchar(255); +alter table migtest_e_history2_history add column obsolete_string2 varchar(255); alter table migtest_e_history4 alter column test_number set data type integer; call sysproc.admin_cmd('reorg table migtest_e_history4'); +alter table migtest_e_history4_history alter column test_number set data type integer; +call sysproc.admin_cmd('reorg table migtest_e_history4_history'); alter table migtest_e_history6 alter column test_number1 drop default; alter table migtest_e_history6 alter column test_number1 drop not 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; call sysproc.admin_cmd('reorg table migtest_e_history6'); +alter table migtest_e_history6_history alter column test_number1 drop not null; +alter table migtest_e_history6_history alter column test_number2 set not null; +call sysproc.admin_cmd('reorg table migtest_e_history6_history'); -- apply post alter alter table migtest_e_ref add constraint uq_mgtst__rf_nm unique (name); alter table migtest_e_basic add constraint ck_mgtst__bsc_stts check ( status in ('N','A','I')); @@ -194,6 +206,10 @@ create unique index uq_mgtst__b_4ayc02 on migtest_e_basic(indextest6) exclude nu alter table migtest_e_enum add constraint ck_mgtst__n_773sok 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 add versioning use history table migtest_e_history2_history; +alter table migtest_e_history3 add versioning use history table migtest_e_history3_history; +alter table migtest_e_history4 add versioning use history table migtest_e_history4_history; +alter table migtest_e_history6 add versioning use history table migtest_e_history6_history; -- foreign keys and indices alter table migtest_fk_cascade add constraint fk_mgtst_fk_65kf6l foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; 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 on update restrict; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.4__dropsFor_1.3.sql index 98a76eaf1..5542a954f 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.4__dropsFor_1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.4__dropsFor_1.3.sql @@ -1,4 +1,9 @@ -- Migrationscripts for ebean unittest +-- apply changes +alter table migtest_e_history drop versioning; +alter table migtest_e_history drop period system_time; +alter table migtest_e_history2 drop versioning; +alter table migtest_e_history5 drop versioning; -- apply alter tables alter table migtest_ckey_detail drop column one_key; alter table migtest_ckey_detail drop column two_key; @@ -11,17 +16,30 @@ alter table migtest_e_basic drop column new_boolean_field2; alter table migtest_e_basic drop column progress; alter table migtest_e_basic drop column new_integer; call sysproc.admin_cmd('reorg table migtest_e_basic'); +alter table migtest_e_history drop column sys_period_start; +alter table migtest_e_history drop column sys_period_end; +alter table migtest_e_history drop column sys_period_txn; +call sysproc.admin_cmd('reorg table migtest_e_history'); alter table migtest_e_history2 drop column test_string2; alter table migtest_e_history2 drop column test_string3; alter table migtest_e_history2 drop column new_column; call sysproc.admin_cmd('reorg table migtest_e_history2'); +alter table migtest_e_history2_history drop column test_string2; +alter table migtest_e_history2_history drop column test_string3; +alter table migtest_e_history2_history drop column new_column; +call sysproc.admin_cmd('reorg table migtest_e_history2_history'); alter table migtest_e_history5 drop column test_boolean; call sysproc.admin_cmd('reorg table migtest_e_history5'); +alter table migtest_e_history5_history drop column test_boolean; +call sysproc.admin_cmd('reorg table migtest_e_history5_history'); alter table migtest_e_softdelete drop column deleted; call sysproc.admin_cmd('reorg table migtest_e_softdelete'); alter table migtest_oto_child drop column master_id; call sysproc.admin_cmd('reorg table migtest_oto_child'); -- apply post alter +drop table migtest_e_history_history; +alter table migtest_e_history2 add versioning use history table migtest_e_history2_history; +alter table migtest_e_history5 add versioning use history table migtest_e_history5_history; drop table migtest_e_user; delimiter $$ begin diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_db2.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_db2.migrations index 02be135d7..b3d6b8896 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_db2.migrations +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_db2.migrations @@ -1,7 +1,7 @@ --91718719, 1.0__initial.sql -827855272, 1.1.sql -859277843, 1.2__dropsFor_1.1.sql -1257741278, 1.3.sql -1763447809, 1.4__dropsFor_1.3.sql +1034179507, 1.0__initial.sql +-1206845521, 1.1.sql +364066694, 1.2__dropsFor_1.1.sql +161683967, 1.3.sql +-1199420632, 1.4__dropsFor_1.3.sql 561281075, R__order_views.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 8298c9fa9..d9e893947 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 @@ -159,9 +159,73 @@ create table migtest_oto_master ( constraint pk_migtest_oto_master primary key (id) ); +-- apply alter tables +alter table migtest_e_history2 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history2 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history2 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history2 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history3 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history3 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history3 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history3 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history4 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history4 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history4 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history4 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history5 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history5 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history5 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history5 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history6 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history6 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history6 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history6 add period system_time (sys_period_start,sys_period_end); -- apply post alter 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; +create table migtest_e_history2_history ( + id integer not null, + test_string varchar(255), + obsolete_string1 varchar(255), + obsolete_string2 varchar(255), + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history2 add versioning use history table migtest_e_history2_history; +create table migtest_e_history3_history ( + id integer not null, + test_string varchar(255), + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history3 add versioning use history table migtest_e_history3_history; +create table migtest_e_history4_history ( + id integer not null, + test_number integer, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history4 add versioning use history table migtest_e_history4_history; +create table migtest_e_history5_history ( + id integer not null, + test_number integer, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history5 add versioning use history table migtest_e_history5_history; +create table migtest_e_history6_history ( + id integer not null, + test_number1 integer, + test_number2 integer not null, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history6 add versioning use history table migtest_e_history6_history; alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name); -- foreign keys and indices create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id); 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 40ebaa171..77c49370e 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 @@ -110,9 +110,14 @@ insert into migtest_e_user (id) select distinct user_id from migtest_e_basic; -- 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 drop versioning; +alter table migtest_e_history3 drop versioning; +alter table migtest_e_history4 drop versioning; +alter table migtest_e_history5 drop versioning; -- 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 drop versioning; -- apply alter tables alter table migtest_ckey_detail add column one_key integer; alter table migtest_ckey_detail add column two_key varchar(127); @@ -129,6 +134,10 @@ alter table migtest_e_basic add column new_boolean_field2 boolean default true n alter table migtest_e_basic add column progress integer default 0 not null; alter table migtest_e_basic add column new_integer integer default 42 not null; call sysproc.admin_cmd('reorg table migtest_e_basic'); +alter table migtest_e_history add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history add period system_time (sys_period_start,sys_period_end); alter table migtest_e_history alter column test_string set data type bigint; call sysproc.admin_cmd('reorg table migtest_e_history'); alter table migtest_e_history2 alter column test_string set default 'unknown'; @@ -137,13 +146,24 @@ alter table migtest_e_history2 add column test_string2 varchar(255); alter table migtest_e_history2 add column test_string3 varchar(255) default 'unknown' not null; alter table migtest_e_history2 add column new_column varchar(20); call sysproc.admin_cmd('reorg table migtest_e_history2'); +alter table migtest_e_history2_history alter column test_string set not null; +alter table migtest_e_history2_history add column test_string2 varchar(255); +alter table migtest_e_history2_history add column test_string3 varchar(255) default 'unknown' not null; +alter table migtest_e_history2_history add column new_column varchar(20); +call sysproc.admin_cmd('reorg table migtest_e_history2_history'); alter table migtest_e_history4 alter column test_number set data type bigint; call sysproc.admin_cmd('reorg table migtest_e_history4'); +alter table migtest_e_history4_history alter column test_number set data type bigint; +call sysproc.admin_cmd('reorg table migtest_e_history4_history'); alter table migtest_e_history5 add column test_boolean boolean default false not null; +alter table migtest_e_history5_history add column test_boolean boolean default false not null; alter table migtest_e_history6 alter column test_number1 set default 42; alter table migtest_e_history6 alter column test_number1 set not null; alter table migtest_e_history6 alter column test_number2 drop not null; call sysproc.admin_cmd('reorg table migtest_e_history6'); +alter table migtest_e_history6_history alter column test_number1 set not null; +alter table migtest_e_history6_history alter column test_number2 drop not null; +call sysproc.admin_cmd('reorg table migtest_e_history6_history'); alter table migtest_e_softdelete add column deleted boolean default false not null; alter table migtest_oto_child add column master_id bigint; -- apply post alter @@ -157,8 +177,21 @@ create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(stat 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; +create table migtest_e_history_history ( + id integer not null, + test_string bigint, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history add versioning use history table migtest_e_history_history; comment on column migtest_e_history.test_string is 'Column altered to long now'; comment on table migtest_e_history is 'We have history now'; +alter table migtest_e_history2 add versioning use history table migtest_e_history2_history; +alter table migtest_e_history3 add versioning use history table migtest_e_history3_history; +alter table migtest_e_history4 add versioning use history table migtest_e_history4_history; +alter table migtest_e_history5 add versioning use history table migtest_e_history5_history; +alter table migtest_e_history6 add versioning use history table migtest_e_history6_history; -- foreign keys and indices 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 on update restrict; 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 50f34feed..7f78aa9b3 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 @@ -1,4 +1,6 @@ -- Migrationscripts for ebean unittest +-- apply changes +alter table migtest_e_history2 drop versioning; -- apply alter tables alter table migtest_e_basic drop column description_file; alter table migtest_e_basic drop column old_boolean; @@ -8,7 +10,11 @@ call sysproc.admin_cmd('reorg table migtest_e_basic'); alter table migtest_e_history2 drop column obsolete_string1; alter table migtest_e_history2 drop column obsolete_string2; call sysproc.admin_cmd('reorg table migtest_e_history2'); +alter table migtest_e_history2_history drop column obsolete_string1; +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 migtest_e_ref; delimiter $$ begin 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 ac5a82ecc..c0280ba4f 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 @@ -158,6 +158,10 @@ create table migtest_e_ref ( update migtest_e_basic set status2 = 'N' where status2 is null; update migtest_e_basic set user_id = 23 where user_id is null; +alter table migtest_e_history2 drop versioning; +alter table migtest_e_history3 drop versioning; +alter table migtest_e_history4 drop versioning; +alter table migtest_e_history6 drop versioning; -- NOTE: table has @History - special migration may be necessary update migtest_e_history6 set test_number2 = 7 where test_number2 is null; @@ -178,13 +182,21 @@ alter table migtest_e_history2 alter column test_string drop default; alter table migtest_e_history2 alter column test_string drop not null; alter table migtest_e_history2 add column obsolete_string1 varchar(255); alter table migtest_e_history2 add column obsolete_string2 varchar(255); +alter table migtest_e_history2_history alter column test_string drop not null; +alter table migtest_e_history2_history add column obsolete_string1 varchar(255); +alter table migtest_e_history2_history add column obsolete_string2 varchar(255); alter table migtest_e_history4 alter column test_number set data type integer; call sysproc.admin_cmd('reorg table migtest_e_history4'); +alter table migtest_e_history4_history alter column test_number set data type integer; +call sysproc.admin_cmd('reorg table migtest_e_history4_history'); alter table migtest_e_history6 alter column test_number1 drop default; alter table migtest_e_history6 alter column test_number1 drop not 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; call sysproc.admin_cmd('reorg table migtest_e_history6'); +alter table migtest_e_history6_history alter column test_number1 drop not null; +alter table migtest_e_history6_history alter column test_number2 set not null; +call sysproc.admin_cmd('reorg table migtest_e_history6_history'); -- apply post alter alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name); alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I')); @@ -194,6 +206,10 @@ create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) 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 add versioning use history table migtest_e_history2_history; +alter table migtest_e_history3 add versioning use history table migtest_e_history3_history; +alter table migtest_e_history4 add versioning use history table migtest_e_history4_history; +alter table migtest_e_history6 add versioning use history table migtest_e_history6_history; -- foreign keys and indices 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; 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; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.4__dropsFor_1.3.sql index 98a76eaf1..5542a954f 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.4__dropsFor_1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.4__dropsFor_1.3.sql @@ -1,4 +1,9 @@ -- Migrationscripts for ebean unittest +-- apply changes +alter table migtest_e_history drop versioning; +alter table migtest_e_history drop period system_time; +alter table migtest_e_history2 drop versioning; +alter table migtest_e_history5 drop versioning; -- apply alter tables alter table migtest_ckey_detail drop column one_key; alter table migtest_ckey_detail drop column two_key; @@ -11,17 +16,30 @@ alter table migtest_e_basic drop column new_boolean_field2; alter table migtest_e_basic drop column progress; alter table migtest_e_basic drop column new_integer; call sysproc.admin_cmd('reorg table migtest_e_basic'); +alter table migtest_e_history drop column sys_period_start; +alter table migtest_e_history drop column sys_period_end; +alter table migtest_e_history drop column sys_period_txn; +call sysproc.admin_cmd('reorg table migtest_e_history'); alter table migtest_e_history2 drop column test_string2; alter table migtest_e_history2 drop column test_string3; alter table migtest_e_history2 drop column new_column; call sysproc.admin_cmd('reorg table migtest_e_history2'); +alter table migtest_e_history2_history drop column test_string2; +alter table migtest_e_history2_history drop column test_string3; +alter table migtest_e_history2_history drop column new_column; +call sysproc.admin_cmd('reorg table migtest_e_history2_history'); alter table migtest_e_history5 drop column test_boolean; call sysproc.admin_cmd('reorg table migtest_e_history5'); +alter table migtest_e_history5_history drop column test_boolean; +call sysproc.admin_cmd('reorg table migtest_e_history5_history'); alter table migtest_e_softdelete drop column deleted; call sysproc.admin_cmd('reorg table migtest_e_softdelete'); alter table migtest_oto_child drop column master_id; call sysproc.admin_cmd('reorg table migtest_oto_child'); -- apply post alter +drop table migtest_e_history_history; +alter table migtest_e_history2 add versioning use history table migtest_e_history2_history; +alter table migtest_e_history5 add versioning use history table migtest_e_history5_history; drop table migtest_e_user; delimiter $$ begin 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 4209b5501..17aaf2093 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,7 +1,7 @@ --583456994, 1.0__initial.sql --40028187, 1.1.sql -859277843, 1.2__dropsFor_1.1.sql --1165877856, 1.3.sql -1763447809, 1.4__dropsFor_1.3.sql +-1345631840, 1.0__initial.sql +2135835079, 1.1.sql +364066694, 1.2__dropsFor_1.1.sql +-1510901098, 1.3.sql +-1199420632, 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 8298c9fa9..d9e893947 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 @@ -159,9 +159,73 @@ create table migtest_oto_master ( constraint pk_migtest_oto_master primary key (id) ); +-- apply alter tables +alter table migtest_e_history2 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history2 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history2 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history2 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history3 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history3 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history3 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history3 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history4 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history4 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history4 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history4 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history5 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history5 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history5 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history5 add period system_time (sys_period_start,sys_period_end); +alter table migtest_e_history6 add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history6 add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history6 add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history6 add period system_time (sys_period_start,sys_period_end); -- apply post alter 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; +create table migtest_e_history2_history ( + id integer not null, + test_string varchar(255), + obsolete_string1 varchar(255), + obsolete_string2 varchar(255), + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history2 add versioning use history table migtest_e_history2_history; +create table migtest_e_history3_history ( + id integer not null, + test_string varchar(255), + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history3 add versioning use history table migtest_e_history3_history; +create table migtest_e_history4_history ( + id integer not null, + test_number integer, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history4 add versioning use history table migtest_e_history4_history; +create table migtest_e_history5_history ( + id integer not null, + test_number integer, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history5 add versioning use history table migtest_e_history5_history; +create table migtest_e_history6_history ( + id integer not null, + test_number1 integer, + test_number2 integer not null, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history6 add versioning use history table migtest_e_history6_history; alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name); -- foreign keys and indices create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id); 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 40ebaa171..77c49370e 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 @@ -110,9 +110,14 @@ insert into migtest_e_user (id) select distinct user_id from migtest_e_basic; -- 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 drop versioning; +alter table migtest_e_history3 drop versioning; +alter table migtest_e_history4 drop versioning; +alter table migtest_e_history5 drop versioning; -- 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 drop versioning; -- apply alter tables alter table migtest_ckey_detail add column one_key integer; alter table migtest_ckey_detail add column two_key varchar(127); @@ -129,6 +134,10 @@ alter table migtest_e_basic add column new_boolean_field2 boolean default true n alter table migtest_e_basic add column progress integer default 0 not null; alter table migtest_e_basic add column new_integer integer default 42 not null; call sysproc.admin_cmd('reorg table migtest_e_basic'); +alter table migtest_e_history add column sys_period_start timestamp(12) not null generated always as row begin; +alter table migtest_e_history add column sys_period_end timestamp(12) not null generated always as row end; +alter table migtest_e_history add column sys_period_txn timestamp(12) generated always as transaction start id; +alter table migtest_e_history add period system_time (sys_period_start,sys_period_end); alter table migtest_e_history alter column test_string set data type bigint; call sysproc.admin_cmd('reorg table migtest_e_history'); alter table migtest_e_history2 alter column test_string set default 'unknown'; @@ -137,13 +146,24 @@ alter table migtest_e_history2 add column test_string2 varchar(255); alter table migtest_e_history2 add column test_string3 varchar(255) default 'unknown' not null; alter table migtest_e_history2 add column new_column varchar(20); call sysproc.admin_cmd('reorg table migtest_e_history2'); +alter table migtest_e_history2_history alter column test_string set not null; +alter table migtest_e_history2_history add column test_string2 varchar(255); +alter table migtest_e_history2_history add column test_string3 varchar(255) default 'unknown' not null; +alter table migtest_e_history2_history add column new_column varchar(20); +call sysproc.admin_cmd('reorg table migtest_e_history2_history'); alter table migtest_e_history4 alter column test_number set data type bigint; call sysproc.admin_cmd('reorg table migtest_e_history4'); +alter table migtest_e_history4_history alter column test_number set data type bigint; +call sysproc.admin_cmd('reorg table migtest_e_history4_history'); alter table migtest_e_history5 add column test_boolean boolean default false not null; +alter table migtest_e_history5_history add column test_boolean boolean default false not null; alter table migtest_e_history6 alter column test_number1 set default 42; alter table migtest_e_history6 alter column test_number1 set not null; alter table migtest_e_history6 alter column test_number2 drop not null; call sysproc.admin_cmd('reorg table migtest_e_history6'); +alter table migtest_e_history6_history alter column test_number1 set not null; +alter table migtest_e_history6_history alter column test_number2 drop not null; +call sysproc.admin_cmd('reorg table migtest_e_history6_history'); alter table migtest_e_softdelete add column deleted boolean default false not null; alter table migtest_oto_child add column master_id bigint; -- apply post alter @@ -157,8 +177,21 @@ create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(stat 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; +create table migtest_e_history_history ( + id integer not null, + test_string bigint, + sys_period_start timestamp(12) not null, + sys_period_end timestamp(12) not null, + sys_period_txn timestamp(12) +); +alter table migtest_e_history add versioning use history table migtest_e_history_history; comment on column migtest_e_history.test_string is 'Column altered to long now'; comment on table migtest_e_history is 'We have history now'; +alter table migtest_e_history2 add versioning use history table migtest_e_history2_history; +alter table migtest_e_history3 add versioning use history table migtest_e_history3_history; +alter table migtest_e_history4 add versioning use history table migtest_e_history4_history; +alter table migtest_e_history5 add versioning use history table migtest_e_history5_history; +alter table migtest_e_history6 add versioning use history table migtest_e_history6_history; -- foreign keys and indices 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 on update restrict; 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 50f34feed..7f78aa9b3 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 @@ -1,4 +1,6 @@ -- Migrationscripts for ebean unittest +-- apply changes +alter table migtest_e_history2 drop versioning; -- apply alter tables alter table migtest_e_basic drop column description_file; alter table migtest_e_basic drop column old_boolean; @@ -8,7 +10,11 @@ call sysproc.admin_cmd('reorg table migtest_e_basic'); alter table migtest_e_history2 drop column obsolete_string1; alter table migtest_e_history2 drop column obsolete_string2; call sysproc.admin_cmd('reorg table migtest_e_history2'); +alter table migtest_e_history2_history drop column obsolete_string1; +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 migtest_e_ref; delimiter $$ begin 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 ac5a82ecc..c0280ba4f 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 @@ -158,6 +158,10 @@ create table migtest_e_ref ( update migtest_e_basic set status2 = 'N' where status2 is null; update migtest_e_basic set user_id = 23 where user_id is null; +alter table migtest_e_history2 drop versioning; +alter table migtest_e_history3 drop versioning; +alter table migtest_e_history4 drop versioning; +alter table migtest_e_history6 drop versioning; -- NOTE: table has @History - special migration may be necessary update migtest_e_history6 set test_number2 = 7 where test_number2 is null; @@ -178,13 +182,21 @@ alter table migtest_e_history2 alter column test_string drop default; alter table migtest_e_history2 alter column test_string drop not null; alter table migtest_e_history2 add column obsolete_string1 varchar(255); alter table migtest_e_history2 add column obsolete_string2 varchar(255); +alter table migtest_e_history2_history alter column test_string drop not null; +alter table migtest_e_history2_history add column obsolete_string1 varchar(255); +alter table migtest_e_history2_history add column obsolete_string2 varchar(255); alter table migtest_e_history4 alter column test_number set data type integer; call sysproc.admin_cmd('reorg table migtest_e_history4'); +alter table migtest_e_history4_history alter column test_number set data type integer; +call sysproc.admin_cmd('reorg table migtest_e_history4_history'); alter table migtest_e_history6 alter column test_number1 drop default; alter table migtest_e_history6 alter column test_number1 drop not 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; call sysproc.admin_cmd('reorg table migtest_e_history6'); +alter table migtest_e_history6_history alter column test_number1 drop not null; +alter table migtest_e_history6_history alter column test_number2 set not null; +call sysproc.admin_cmd('reorg table migtest_e_history6_history'); -- apply post alter alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name); alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I')); @@ -194,6 +206,10 @@ create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) 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 add versioning use history table migtest_e_history2_history; +alter table migtest_e_history3 add versioning use history table migtest_e_history3_history; +alter table migtest_e_history4 add versioning use history table migtest_e_history4_history; +alter table migtest_e_history6 add versioning use history table migtest_e_history6_history; -- foreign keys and indices 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; 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; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.4__dropsFor_1.3.sql index 98a76eaf1..5542a954f 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.4__dropsFor_1.3.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.4__dropsFor_1.3.sql @@ -1,4 +1,9 @@ -- Migrationscripts for ebean unittest +-- apply changes +alter table migtest_e_history drop versioning; +alter table migtest_e_history drop period system_time; +alter table migtest_e_history2 drop versioning; +alter table migtest_e_history5 drop versioning; -- apply alter tables alter table migtest_ckey_detail drop column one_key; alter table migtest_ckey_detail drop column two_key; @@ -11,17 +16,30 @@ alter table migtest_e_basic drop column new_boolean_field2; alter table migtest_e_basic drop column progress; alter table migtest_e_basic drop column new_integer; call sysproc.admin_cmd('reorg table migtest_e_basic'); +alter table migtest_e_history drop column sys_period_start; +alter table migtest_e_history drop column sys_period_end; +alter table migtest_e_history drop column sys_period_txn; +call sysproc.admin_cmd('reorg table migtest_e_history'); alter table migtest_e_history2 drop column test_string2; alter table migtest_e_history2 drop column test_string3; alter table migtest_e_history2 drop column new_column; call sysproc.admin_cmd('reorg table migtest_e_history2'); +alter table migtest_e_history2_history drop column test_string2; +alter table migtest_e_history2_history drop column test_string3; +alter table migtest_e_history2_history drop column new_column; +call sysproc.admin_cmd('reorg table migtest_e_history2_history'); alter table migtest_e_history5 drop column test_boolean; call sysproc.admin_cmd('reorg table migtest_e_history5'); +alter table migtest_e_history5_history drop column test_boolean; +call sysproc.admin_cmd('reorg table migtest_e_history5_history'); alter table migtest_e_softdelete drop column deleted; call sysproc.admin_cmd('reorg table migtest_e_softdelete'); alter table migtest_oto_child drop column master_id; call sysproc.admin_cmd('reorg table migtest_oto_child'); -- apply post alter +drop table migtest_e_history_history; +alter table migtest_e_history2 add versioning use history table migtest_e_history2_history; +alter table migtest_e_history5 add versioning use history table migtest_e_history5_history; drop table migtest_e_user; delimiter $$ begin 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 4209b5501..17aaf2093 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 @@ --583456994, 1.0__initial.sql --40028187, 1.1.sql -859277843, 1.2__dropsFor_1.1.sql --1165877856, 1.3.sql -1763447809, 1.4__dropsFor_1.3.sql +-1345631840, 1.0__initial.sql +2135835079, 1.1.sql +364066694, 1.2__dropsFor_1.1.sql +-1510901098, 1.3.sql +-1199420632, 1.4__dropsFor_1.3.sql 561281075, R__order_views.sql