migration scripts

This commit is contained in:
Noemi Praml
2022-09-02 10:09:50 +02:00
parent 315b6b8995
commit 5a0976e596
123 changed files with 535 additions and 122 deletions
@@ -126,7 +126,8 @@ create table "table" (
"from" String,
"to" String,
"varchar" String,
"foreign" String
"foreign" String,
textfield String
) ENGINE = Log();
create table migtest_mtm_c (
@@ -38,7 +38,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
alter table "table" alter column textfield set null;
alter table "table" add column "select" String;
alter table "table" add column textfield2 String;
alter table migtest_ckey_detail add column one_key UInt32;
alter table migtest_ckey_detail add column two_key String;
alter table migtest_ckey_parent add column assoc_id UInt32;
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
alter table "table" drop column textfield;
alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -1,6 +1,6 @@
235371332, 1.0__initial.sql
74490120, 1.1.sql
193400547, 1.0__initial.sql
540706946, 1.1.sql
688811494, 1.2__dropsFor_1.1.sql
1015552567, 1.3.sql
80209848, 1.4__dropsFor_1.3.sql
255653518, 1.4__dropsFor_1.3.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -46,7 +46,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
alter table "table" alter column textfield drop not null;
alter table "table" add column "select" varchar(255);
alter table "table" add column textfield2 varchar(255);
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_parent add column assoc_id integer;
@@ -116,3 +118,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on "table" (textfield2);
@@ -16,6 +16,7 @@ drop index uq_migtest_e_basic_indextest5 cascade;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
alter table "table" drop column textfield;
alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -1,7 +1,7 @@
-703764770, 1.0__initial.sql
773862451, 1.1.sql
1434934404, 1.0__initial.sql
1284257915, 1.1.sql
856096334, 1.2__dropsFor_1.1.sql
17665322, 1.3.sql
-820814009, 1.4__dropsFor_1.3.sql
-1551362011, 1.3.sql
-971909974, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql
@@ -152,6 +152,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
textfield varchar(255) not null,
constraint pk_table primary key ("index")
);
comment on column "table"."index" is 'this is a comment';
@@ -130,7 +130,10 @@ alter table "table" drop versioning;
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_C','TESTTS','TESTTS','TESTTS','','','','','','MOVE');
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_M','TSMASTER','TSMASTER','TSMASTER','','','','','','MOVE');
-- apply alter tables
alter table "table" alter column textfield drop not null;
alter table "table" add column "select" varchar(255);
alter table "table" add column textfield2 varchar(255);
call sysproc.admin_cmd('reorg table "table"');
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_parent add column assoc_id integer;
@@ -180,7 +183,10 @@ 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;
alter table table_history alter column textfield drop not null;
alter table table_history add column "select" varchar(255);
alter table table_history add column textfield2 varchar(255);
call sysproc.admin_cmd('reorg table table_history');
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
create unique index uq_migtest_e_basic_description on migtest_e_basic(description) exclude null keys;
@@ -232,3 +238,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on "table" (textfield2);
@@ -147,6 +147,13 @@ if exists (select indname from syscat.indexes where indschema = current_schema a
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_TABLE_TEXTFIELD2') then
prepare stmt from 'drop index ix_table_textfield2';
execute stmt;
end if;
end$$;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
@@ -200,9 +207,11 @@ 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);
call sysproc.admin_cmd('reorg table migtest_e_history2');
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);
call sysproc.admin_cmd('reorg table migtest_e_history2_history');
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;
@@ -4,7 +4,11 @@ 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;
alter table "table" drop versioning;
-- apply alter tables
alter table "table" drop column textfield;
alter table "table" drop column textfield2;
call sysproc.admin_cmd('reorg table "table"');
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
call sysproc.admin_cmd('reorg table migtest_ckey_detail');
@@ -36,10 +40,14 @@ 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');
alter table table_history drop column textfield;
alter table table_history drop column textfield2;
call sysproc.admin_cmd('reorg table table_history');
-- 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;
alter table "table" add versioning use history table table_history;
drop table migtest_e_user;
delimiter $$
begin
@@ -1,8 +1,8 @@
1873955813, 1.0__initial.sql
-1557626294, 1.1.sql
-1467839063, 1.0__initial.sql
-184000413, 1.1.sql
-1187336846, 1.2__dropsFor_1.1.sql
2066110925, 1.3.sql
-1713819679, 1.4__dropsFor_1.3.sql
-150875853, 1.3.sql
946163478, 1.4__dropsFor_1.3.sql
-133543359, R__db2_explain_tables.sql
561281075, R__order_views.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -46,7 +46,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
alter table "table" alter column textfield set null;
alter table "table" add column "select" varchar(255);
alter table "table" add column textfield2 varchar(255);
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_parent add column assoc_id integer;
@@ -119,3 +121,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on "table" (textfield2);
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
alter table "table" drop column textfield;
alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -1,6 +1,6 @@
-710189690, 1.0__initial.sql
-145836847, 1.1.sql
-1547037623, 1.0__initial.sql
253988246, 1.1.sql
688811494, 1.2__dropsFor_1.1.sql
2025934113, 1.3.sql
80209848, 1.4__dropsFor_1.3.sql
509168727, 1.3.sql
255653518, 1.4__dropsFor_1.3.sql
@@ -152,6 +152,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
textfield varchar(255) not null,
constraint pk_table primary key ("index")
);
comment on column "table"."index" is 'this is a comment';
@@ -130,7 +130,10 @@ alter table "table" drop versioning;
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_C','TESTTS','TESTTS','TESTTS','','','','','','MOVE');
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_M','TSMASTER','TSMASTER','TSMASTER','','','','','','MOVE');
-- apply alter tables
alter table "table" alter column textfield drop not null;
alter table "table" add column "select" varchar(255);
alter table "table" add column textfield2 varchar(255);
call sysproc.admin_cmd('reorg table "table"');
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_parent add column assoc_id integer;
@@ -180,7 +183,10 @@ 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;
alter table table_history alter column textfield drop not null;
alter table table_history add column "select" varchar(255);
alter table table_history add column textfield2 varchar(255);
call sysproc.admin_cmd('reorg table table_history');
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
create unique index uq_migtest_e_basic_description on migtest_e_basic(description) exclude null keys;
@@ -232,3 +238,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on "table" (textfield2);
@@ -147,6 +147,13 @@ if exists (select indname from syscat.indexes where indschema = current_schema a
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_TABLE_TEXTFIELD2') then
prepare stmt from 'drop index ix_table_textfield2';
execute stmt;
end if;
end$$;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
@@ -200,9 +207,11 @@ 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);
call sysproc.admin_cmd('reorg table migtest_e_history2');
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);
call sysproc.admin_cmd('reorg table migtest_e_history2_history');
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;
@@ -4,7 +4,11 @@ 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;
alter table "table" drop versioning;
-- apply alter tables
alter table "table" drop column textfield;
alter table "table" drop column textfield2;
call sysproc.admin_cmd('reorg table "table"');
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
call sysproc.admin_cmd('reorg table migtest_ckey_detail');
@@ -36,10 +40,14 @@ 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');
alter table table_history drop column textfield;
alter table table_history drop column textfield2;
call sysproc.admin_cmd('reorg table table_history');
-- 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;
alter table "table" add versioning use history table table_history;
drop table migtest_e_user;
delimiter $$
begin
@@ -1,9 +1,9 @@
1307787475, I__create_tablespaces.sql
-1998060342, 1.0__initial.sql
1595289592, 1.1.sql
2058232717, 1.0__initial.sql
-1450326352, 1.1.sql
-1187336846, 1.2__dropsFor_1.1.sql
-1088179698, 1.3.sql
-1713819679, 1.4__dropsFor_1.3.sql
1976888196, 1.3.sql
946163478, 1.4__dropsFor_1.3.sql
-133543359, R__db2_explain_tables.sql
561281075, R__order_views.sql
@@ -152,6 +152,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
textfield varchar(255) not null,
constraint pk_table primary key ("index")
);
comment on column "table"."index" is 'this is a comment';
@@ -130,7 +130,10 @@ alter table "table" drop versioning;
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_C','TESTTS','TESTTS','TESTTS','','','','','','MOVE');
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_M','TSMASTER','TSMASTER','TSMASTER','','','','','','MOVE');
-- apply alter tables
alter table "table" alter column textfield drop not null;
alter table "table" add column "select" varchar(255);
alter table "table" add column textfield2 varchar(255);
call sysproc.admin_cmd('reorg table "table"');
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_parent add column assoc_id integer;
@@ -180,7 +183,10 @@ 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;
alter table table_history alter column textfield drop not null;
alter table table_history add column "select" varchar(255);
alter table table_history add column textfield2 varchar(255);
call sysproc.admin_cmd('reorg table table_history');
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
create unique index uq_migtest_e_basic_description on migtest_e_basic(description) exclude null keys;
@@ -232,3 +238,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on "table" (textfield2);
@@ -147,6 +147,13 @@ if exists (select indname from syscat.indexes where indschema = current_schema a
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_TABLE_TEXTFIELD2') then
prepare stmt from 'drop index ix_table_textfield2';
execute stmt;
end if;
end$$;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
@@ -200,9 +207,11 @@ 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);
call sysproc.admin_cmd('reorg table migtest_e_history2');
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);
call sysproc.admin_cmd('reorg table migtest_e_history2_history');
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;
@@ -4,7 +4,11 @@ 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;
alter table "table" drop versioning;
-- apply alter tables
alter table "table" drop column textfield;
alter table "table" drop column textfield2;
call sysproc.admin_cmd('reorg table "table"');
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
call sysproc.admin_cmd('reorg table migtest_ckey_detail');
@@ -36,10 +40,14 @@ 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');
alter table table_history drop column textfield;
alter table table_history drop column textfield2;
call sysproc.admin_cmd('reorg table table_history');
-- 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;
alter table "table" add versioning use history table table_history;
drop table migtest_e_user;
delimiter $$
begin
@@ -1,8 +1,8 @@
-1998060342, 1.0__initial.sql
1595289592, 1.1.sql
2058232717, 1.0__initial.sql
-1450326352, 1.1.sql
-1187336846, 1.2__dropsFor_1.1.sql
-1088179698, 1.3.sql
-1713819679, 1.4__dropsFor_1.3.sql
1976888196, 1.3.sql
946163478, 1.4__dropsFor_1.3.sql
-133543359, R__db2_explain_tables.sql
561281075, R__order_views.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -46,7 +46,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
alter table "table" alter column textfield set null;
alter table "table" add column "select" varchar(255);
alter table "table" add column textfield2 varchar(255);
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_parent add column assoc_id integer;
@@ -119,3 +121,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on "table" (textfield2);
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
alter table "table" drop column textfield;
alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -1,6 +1,6 @@
-710189690, 1.0__initial.sql
-145836847, 1.1.sql
-1547037623, 1.0__initial.sql
253988246, 1.1.sql
688811494, 1.2__dropsFor_1.1.sql
2025934113, 1.3.sql
80209848, 1.4__dropsFor_1.3.sql
509168727, 1.3.sql
255653518, 1.4__dropsFor_1.3.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -254,6 +255,7 @@ create table table_history(
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
textfield varchar(255),
sys_period_start timestamp,
sys_period_end timestamp
);
@@ -58,7 +58,9 @@ drop view migtest_e_history6_with_history;
drop trigger table_history_upd;
drop view table_with_history;
-- apply alter tables
alter table "table" alter column textfield set null;
alter table "table" add column "select" varchar(255);
alter table "table" add column textfield2 varchar(255);
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_parent add column assoc_id integer;
@@ -96,7 +98,9 @@ alter table migtest_e_history6 alter column test_number2 set null;
alter table migtest_e_history6_history alter column test_number2 set null;
alter table migtest_e_softdelete add column deleted boolean default false not null;
alter table migtest_oto_child add column master_id bigint;
alter table table_history alter column textfield set null;
alter table table_history add column "select" varchar(255);
alter table table_history add column textfield2 varchar(255);
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
@@ -161,3 +165,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on "table" (textfield2);
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
@@ -9,7 +9,11 @@ drop trigger migtest_e_history2_history_upd;
drop view migtest_e_history2_with_history;
drop trigger migtest_e_history5_history_upd;
drop view migtest_e_history5_with_history;
drop trigger table_history_upd;
drop view table_with_history;
-- apply alter tables
alter table "table" drop column textfield;
alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -30,11 +34,15 @@ alter table migtest_e_history5 drop column test_boolean;
alter table migtest_e_history5_history drop column test_boolean;
alter table migtest_e_softdelete drop column deleted;
alter table migtest_oto_child drop column master_id;
alter table table_history drop column textfield;
alter table table_history drop column textfield2;
-- apply post alter
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create view table_with_history as select * from "table" union all select * from table_history;
create trigger table_history_upd before update,delete on "table" for each row call "io.ebean.platform.h2.H2HistoryTrigger";
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;
@@ -1,8 +1,8 @@
-1806036603, 1.0__initial.sql
-1296236140, 1.1.sql
-1854589550, 1.0__initial.sql
1979519453, 1.1.sql
1579867974, 1.2__dropsFor_1.1.sql
-877392737, 1.3.sql
116139207, 1.4__dropsFor_1.3.sql
-285485598, 1.3.sql
-1120611041, 1.4__dropsFor_1.3.sql
783227075, R__multi_comments.sql
561281075, R__order_views.sql
@@ -156,6 +156,7 @@ create column table "table" (
"to" nvarchar(255),
"varchar" nvarchar(255),
"foreign" nvarchar(255),
textfield nvarchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -257,6 +258,7 @@ create column table table_history (
"to" nvarchar(255),
"varchar" nvarchar(255),
"foreign" nvarchar(255),
textfield nvarchar(255) not null,
sys_period_start timestamp,
sys_period_end timestamp
);
@@ -100,7 +100,9 @@ update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
alter table migtest_e_history6 drop system versioning;
alter table "table" drop system versioning;
-- apply alter tables
alter table "table" add ("select" nvarchar(255));
alter table "table" alter (textfield nvarchar(255));
alter table "table" add ("select" nvarchar(255),
textfield2 nvarchar(255));
alter table migtest_ckey_detail add (one_key integer,
two_key nvarchar(127));
alter table migtest_ckey_parent add (assoc_id integer);
@@ -130,7 +132,9 @@ alter table migtest_e_history6 alter (test_number1 integer default 42 not null,
alter table migtest_e_history6_history alter (test_number2 integer);
alter table migtest_e_softdelete add (deleted boolean default false not null);
alter table migtest_oto_child add (master_id bigint);
alter table table_history add ("select" nvarchar(255));
alter table table_history alter (textfield nvarchar(255));
alter table table_history add ("select" nvarchar(255),
textfield2 nvarchar(255));
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
-- cannot create unique index "uq_migtest_e_basic_description" on table "migtest_e_basic" with nullable columns;
@@ -192,3 +196,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
-- explicit index "ix_migtest_e_basic_indextest3" for single column "indextest3" of table "migtest_e_basic" is not necessary;
-- explicit index "ix_migtest_e_basic_indextest6" for single column "indextest6" of table "migtest_e_basic" is not necessary;
-- explicit index "ix_table_textfield2" for single column "textfield2" of table ""table"" is not necessary;
@@ -76,6 +76,13 @@ declare exit handler for sql_error_code 261 begin end;
exec 'drop index ix_migtest_e_basic_indextest6';
end;
$$;
delimiter $$
do
begin
declare exit handler for sql_error_code 261 begin end;
exec 'drop index ix_table_textfield2';
end;
$$;
-- apply changes
create column table "migtest_QuOtEd" (
id nvarchar(255) not null,
@@ -7,7 +7,10 @@ drop table migtest_e_history_history cascade;
-- apply changes
alter table migtest_e_history2 drop system versioning;
alter table migtest_e_history5 drop system versioning;
alter table "table" drop system versioning;
-- apply alter tables
CALL usp_ebean_drop_column('"table"', 'textfield');
CALL usp_ebean_drop_column('"table"', 'textfield2');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'one_key');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'two_key');
CALL usp_ebean_drop_column('migtest_ckey_parent', 'assoc_id');
@@ -26,9 +29,12 @@ CALL usp_ebean_drop_column('migtest_e_history5', 'test_boolean');
CALL usp_ebean_drop_column('migtest_e_history5_history', 'test_boolean');
CALL usp_ebean_drop_column('migtest_e_softdelete', 'deleted');
CALL usp_ebean_drop_column('migtest_oto_child', 'master_id');
CALL usp_ebean_drop_column('table_history', 'textfield');
CALL usp_ebean_drop_column('table_history', 'textfield2');
-- apply post alter
alter table migtest_e_history2 add system versioning history table migtest_e_history2_history not validated;
alter table migtest_e_history5 add system versioning history table migtest_e_history5_history not validated;
alter table "table" add system versioning history table table_history not validated;
drop table migtest_e_user cascade;
drop table migtest_mtm_c_migtest_mtm_m cascade;
drop table migtest_mtm_m_migtest_mtm_c cascade;
@@ -1,8 +1,8 @@
-745347271, I__create_procs.sql
1631114894, 1.0__initial.sql
-534043487, 1.1.sql
-2017770851, 1.0__initial.sql
-1727762906, 1.1.sql
1535221752, 1.2__dropsFor_1.1.sql
483907844, 1.3.sql
1812245353, 1.4__dropsFor_1.3.sql
-1046661128, 1.3.sql
1185007986, 1.4__dropsFor_1.3.sql
1906063401, R__order_views_hana.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -46,7 +46,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
alter table "table" alter column textfield set null;
alter table "table" add column "select" varchar(255);
alter table "table" add column textfield2 varchar(255);
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_parent add column assoc_id integer;
@@ -119,3 +121,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on "table" (textfield2);
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
alter table "table" drop column textfield;
alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -1,7 +1,7 @@
-906026927, 1.0__initial.sql
936644233, 1.1.sql
1833930558, 1.0__initial.sql
84224587, 1.1.sql
-848622216, 1.2__dropsFor_1.1.sql
781720387, 1.3.sql
-972999284, 1.4__dropsFor_1.3.sql
19356381, 1.3.sql
1661935263, 1.4__dropsFor_1.3.sql
861001272, R__order_views_hsqldb.sql
@@ -151,6 +151,7 @@ create table `table` (
`to` varchar(255),
`varchar` varchar(255),
`foreign` varchar(255),
textfield varchar(255) not null,
constraint uq_table_to unique (`to`),
constraint uq_table_varchar unique (`varchar`),
constraint pk_table primary key (`index`)
@@ -44,7 +44,9 @@ SET @@system_versioning_alter_history = 1;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
alter table `table` modify textfield varchar(255);
alter table `table` add column `select` varchar(255);
alter table `table` add column textfield2 varchar(255);
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_parent add column assoc_id integer;
@@ -108,3 +110,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on `table` (textfield2);
@@ -13,6 +13,7 @@ alter table migtest_e_basic drop index uq_migtest_e_basic_indextest4;
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest5;
drop index ix_migtest_e_basic_indextest3 on migtest_e_basic;
drop index ix_migtest_e_basic_indextest6 on migtest_e_basic;
drop index ix_table_textfield2 on `table`;
-- apply changes
create table `migtest_QuOtEd` (
id varchar(255) not null,
@@ -2,6 +2,8 @@
-- apply changes
SET @@system_versioning_alter_history = 1;
-- apply alter tables
alter table `table` drop column textfield;
alter table `table` drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -1,7 +1,7 @@
168258180, 1.0__initial.sql
1552926718, 1.1.sql
-2111548334, 1.0__initial.sql
-1101751768, 1.1.sql
919151678, 1.2__dropsFor_1.1.sql
-1031408459, 1.3.sql
-446860935, 1.4__dropsFor_1.3.sql
-1572621686, 1.3.sql
1686135364, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql
@@ -151,6 +151,7 @@ create table `table` (
`to` varchar(255),
`varchar` varchar(255),
`foreign` varchar(255),
textfield varchar(255) not null,
constraint uq_table_to unique (`to`),
constraint uq_table_varchar unique (`varchar`),
constraint pk_table primary key (`index`)
@@ -44,7 +44,9 @@ SET @@system_versioning_alter_history = 1;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
alter table `table` modify textfield varchar(255);
alter table `table` add column `select` varchar(255);
alter table `table` add column textfield2 varchar(255);
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_parent add column assoc_id integer;
@@ -108,3 +110,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on `table` (textfield2);
@@ -13,6 +13,7 @@ alter table migtest_e_basic drop index uq_migtest_e_basic_indextest4;
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest5;
drop index ix_migtest_e_basic_indextest3 on migtest_e_basic;
drop index ix_migtest_e_basic_indextest6 on migtest_e_basic;
drop index ix_table_textfield2 on `table`;
-- apply changes
create table `migtest_QuOtEd` (
id varchar(255) not null,
@@ -2,6 +2,8 @@
-- apply changes
SET @@system_versioning_alter_history = 1;
-- apply alter tables
CALL usp_ebean_drop_column('table', 'textfield');
CALL usp_ebean_drop_column('table', 'textfield2');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'one_key');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'two_key');
CALL usp_ebean_drop_column('migtest_ckey_parent', 'assoc_id');
@@ -1,8 +1,8 @@
1835064798, I__create_procs.sql
168258180, 1.0__initial.sql
1552926718, 1.1.sql
-2111548334, 1.0__initial.sql
-1101751768, 1.1.sql
1187950993, 1.2__dropsFor_1.1.sql
-1031408459, 1.3.sql
-692020559, 1.4__dropsFor_1.3.sql
-1572621686, 1.3.sql
772508824, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql
@@ -112,6 +112,7 @@
<column name="&quot;to&quot;" type="varchar"/>
<column name="&quot;varchar&quot;" type="varchar"/>
<column name="&quot;foreign&quot;" type="varchar" references="&quot;table&quot;.&quot;index&quot;" foreignKeyName="fk_table_foreign" foreignKeyIndex="ix_table_foreign"/>
<column name="textfield" type="varchar" notnull="true"/>
<uniqueConstraint name="uq_table_to" columnNames="&quot;to&quot;" oneToOne="false" nullableColumns="&quot;to&quot;"/>
<uniqueConstraint name="uq_table_varchar" columnNames="&quot;varchar&quot;" oneToOne="false" nullableColumns="&quot;varchar&quot;"/>
</createTable>
@@ -73,8 +73,10 @@
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
</addColumn>
<alterColumn columnName="&quot;index&quot;" tableName="&quot;table&quot;" withHistory="true" comment="this is an other comment"/>
<alterColumn columnName="textfield" tableName="&quot;table&quot;" withHistory="true" currentType="varchar" notnull="false" currentNotnull="true"/>
<addColumn tableName="&quot;table&quot;" withHistory="true">
<column name="&quot;select&quot;" type="varchar"/>
<column name="textfield2" type="varchar"/>
</addColumn>
<addUniqueConstraint constraintName="uq_table_select" tableName="&quot;table&quot;" columnNames="&quot;select&quot;" oneToOne="false" nullableColumns="&quot;select&quot;"/>
<createTable name="migtest_e_user" pkName="pk_migtest_e_user">
@@ -103,6 +105,7 @@
</addColumn>
<createIndex indexName="ix_migtest_e_basic_indextest3" tableName="migtest_e_basic" columns="indextest3"/>
<createIndex indexName="ix_migtest_e_basic_indextest6" tableName="migtest_e_basic" columns="indextest6"/>
<createIndex indexName="ix_table_textfield2" tableName="&quot;table&quot;" columns="textfield2"/>
<createIndex indexName="ix_migtest_oto_child_name" tableName="migtest_oto_child" columns="name" platforms="POSTGRES"/>
<dropIndex indexName="ix_migtest_e_basic_indextest1" tableName="migtest_e_basic"/>
<dropIndex indexName="ix_migtest_e_basic_indextest5" tableName="migtest_e_basic"/>
@@ -61,6 +61,7 @@
<createIndex indexName="ix_migtest_oto_master_lowername" tableName="migtest_oto_master" columns="lower(name)" unique="true" platforms="POSTGRES"/>
<dropIndex indexName="ix_migtest_e_basic_indextest3" tableName="migtest_e_basic"/>
<dropIndex indexName="ix_migtest_e_basic_indextest6" tableName="migtest_e_basic"/>
<dropIndex indexName="ix_table_textfield2" tableName="&quot;table&quot;"/>
</changeSet>
<changeSet type="pendingDrops">
<dropColumn columnName="one_key" tableName="migtest_ckey_detail"/>
@@ -77,6 +78,8 @@
<dropColumn columnName="new_column" tableName="migtest_e_history2" withHistory="true"/>
<dropColumn columnName="test_boolean" tableName="migtest_e_history5" withHistory="true"/>
<dropColumn columnName="deleted" tableName="migtest_e_softdelete"/>
<dropColumn columnName="textfield" tableName="&quot;table&quot;" withHistory="true"/>
<dropColumn columnName="textfield2" tableName="&quot;table&quot;" withHistory="true"/>
<dropColumn columnName="master_id" tableName="migtest_oto_child"/>
<dropTable name="migtest_e_user" sequenceCol="id"/>
<dropTable name="migtest_mtm_c_migtest_mtm_m"/>
@@ -15,6 +15,8 @@
<dropColumn columnName="new_column" tableName="migtest_e_history2" withHistory="true"/>
<dropColumn columnName="test_boolean" tableName="migtest_e_history5" withHistory="true"/>
<dropColumn columnName="deleted" tableName="migtest_e_softdelete"/>
<dropColumn columnName="textfield" tableName="&quot;table&quot;" withHistory="true"/>
<dropColumn columnName="textfield2" tableName="&quot;table&quot;" withHistory="true"/>
<dropColumn columnName="master_id" tableName="migtest_oto_child"/>
<dropTable name="migtest_e_user" sequenceCol="id"/>
<dropTable name="migtest_mtm_c_migtest_mtm_m"/>
@@ -151,6 +151,7 @@ create table `table` (
`to` varchar(255),
`varchar` varchar(255),
`foreign` varchar(255),
textfield varchar(255) not null,
constraint uq_table_to unique (`to`),
constraint uq_table_varchar unique (`varchar`),
constraint pk_table primary key (`index`)
@@ -298,6 +299,7 @@ create table table_history(
`to` varchar(255),
`varchar` varchar(255),
`foreign` varchar(255),
textfield varchar(255),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
@@ -305,12 +307,12 @@ create view table_with_history as select * from `table` union all select * from
lock tables `table` write;
delimiter $$
create trigger table_history_upd before update on `table` for each row begin
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`);
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`, textfield) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`, OLD.textfield);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger table_history_del before delete on `table` for each row begin
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`);
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`, textfield) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`, OLD.textfield);
end$$
unlock tables;
@@ -61,7 +61,9 @@ drop trigger table_history_upd;
drop trigger table_history_del;
drop view table_with_history;
-- apply alter tables
alter table `table` modify textfield varchar(255);
alter table `table` add column `select` varchar(255);
alter table `table` add column textfield2 varchar(255);
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_parent add column assoc_id integer;
@@ -93,7 +95,9 @@ alter table migtest_e_history6 modify test_number2 integer;
alter table migtest_e_history6_history modify test_number2 integer;
alter table migtest_e_softdelete add column deleted tinyint(1) default 0 not null;
alter table migtest_oto_child add column master_id bigint;
alter table table_history modify textfield varchar(255);
alter table table_history add column `select` varchar(255);
alter table table_history add column textfield2 varchar(255);
-- apply post alter
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
update migtest_e_basic set new_boolean_field = old_boolean;
@@ -186,12 +190,12 @@ create view table_with_history as select * from `table` union all select * from
lock tables `table` write;
delimiter $$
create trigger table_history_upd before update on `table` for each row begin
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`, textfield, textfield2) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`, OLD.textfield, OLD.textfield2);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger table_history_del before delete on `table` for each row begin
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`, textfield, textfield2) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`, OLD.textfield, OLD.textfield2);
end$$
unlock tables;
alter table `table` add constraint uq_table_select unique (`select`);
@@ -224,3 +228,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on `table` (textfield2);
@@ -13,6 +13,7 @@ alter table migtest_e_basic drop index uq_migtest_e_basic_indextest4;
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest5;
drop index ix_migtest_e_basic_indextest3 on migtest_e_basic;
drop index ix_migtest_e_basic_indextest6 on migtest_e_basic;
drop index ix_table_textfield2 on `table`;
-- apply changes
create table `migtest_QuOtEd` (
id varchar(255) not null,
@@ -12,7 +12,12 @@ drop view migtest_e_history2_with_history;
drop trigger migtest_e_history5_history_upd;
drop trigger migtest_e_history5_history_del;
drop view migtest_e_history5_with_history;
drop trigger table_history_upd;
drop trigger table_history_del;
drop view table_with_history;
-- apply alter tables
CALL usp_ebean_drop_column('table', 'textfield');
CALL usp_ebean_drop_column('table', 'textfield2');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'one_key');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'two_key');
CALL usp_ebean_drop_column('migtest_ckey_parent', 'assoc_id');
@@ -33,6 +38,8 @@ CALL usp_ebean_drop_column('migtest_e_history5', 'test_boolean');
CALL usp_ebean_drop_column('migtest_e_history5_history', 'test_boolean');
CALL usp_ebean_drop_column('migtest_e_softdelete', 'deleted');
CALL usp_ebean_drop_column('migtest_oto_child', 'master_id');
CALL usp_ebean_drop_column('table_history', 'textfield');
CALL usp_ebean_drop_column('table_history', 'textfield2');
-- apply post alter
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
lock tables migtest_e_history2 write;
@@ -58,6 +65,18 @@ create trigger migtest_e_history5_history_del before delete on migtest_e_history
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$$
unlock tables;
create view table_with_history as select * from `table` union all select * from table_history;
lock tables `table` write;
delimiter $$
create trigger table_history_upd before update on `table` for each row begin
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger table_history_del before delete on `table` for each row begin
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
end$$
unlock tables;
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;
@@ -1,8 +1,8 @@
1835064798, I__create_procs.sql
776107385, 1.0__initial.sql
-1234435534, 1.1.sql
1980830787, 1.0__initial.sql
-92753611, 1.1.sql
-1097227916, 1.2__dropsFor_1.1.sql
-1972055805, 1.3.sql
379252952, 1.4__dropsFor_1.3.sql
1674664705, 1.3.sql
-1282113429, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql
@@ -151,6 +151,7 @@ create table `table` (
`to` varchar(255),
`varchar` varchar(255),
`foreign` varchar(255),
textfield varchar(255) not null,
constraint uq_table_to unique (`to`),
constraint uq_table_varchar unique (`varchar`),
constraint pk_table primary key (`index`)
@@ -298,6 +299,7 @@ create table table_history(
`to` varchar(255),
`varchar` varchar(255),
`foreign` varchar(255),
textfield varchar(255),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
@@ -305,12 +307,12 @@ create view table_with_history as select * from `table` union all select * from
lock tables `table` write;
delimiter $$
create trigger table_history_upd before update on `table` for each row begin
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`);
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`, textfield) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`, OLD.textfield);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger table_history_del before delete on `table` for each row begin
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`);
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`, textfield) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`, OLD.textfield);
end$$
unlock tables;
@@ -61,7 +61,9 @@ drop trigger table_history_upd;
drop trigger table_history_del;
drop view table_with_history;
-- apply alter tables
alter table `table` modify textfield varchar(255);
alter table `table` add column `select` varchar(255);
alter table `table` add column textfield2 varchar(255);
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_parent add column assoc_id integer;
@@ -93,7 +95,9 @@ alter table migtest_e_history6 modify test_number2 integer;
alter table migtest_e_history6_history modify test_number2 integer;
alter table migtest_e_softdelete add column deleted tinyint(1) default 0 not null;
alter table migtest_oto_child add column master_id bigint;
alter table table_history modify textfield varchar(255);
alter table table_history add column `select` varchar(255);
alter table table_history add column textfield2 varchar(255);
-- apply post alter
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
update migtest_e_basic set new_boolean_field = old_boolean;
@@ -186,12 +190,12 @@ create view table_with_history as select * from `table` union all select * from
lock tables `table` write;
delimiter $$
create trigger table_history_upd before update on `table` for each row begin
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`, textfield, textfield2) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`, OLD.textfield, OLD.textfield2);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger table_history_del before delete on `table` for each row begin
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`, textfield, textfield2) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`, OLD.textfield, OLD.textfield2);
end$$
unlock tables;
alter table `table` add constraint uq_table_select unique (`select`);
@@ -224,3 +228,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on `table` (textfield2);
@@ -13,6 +13,7 @@ alter table migtest_e_basic drop index uq_migtest_e_basic_indextest4;
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest5;
drop index ix_migtest_e_basic_indextest3 on migtest_e_basic;
drop index ix_migtest_e_basic_indextest6 on migtest_e_basic;
drop index ix_table_textfield2 on `table`;
-- apply changes
create table `migtest_QuOtEd` (
id varchar(255) not null,
@@ -12,7 +12,12 @@ drop view migtest_e_history2_with_history;
drop trigger migtest_e_history5_history_upd;
drop trigger migtest_e_history5_history_del;
drop view migtest_e_history5_with_history;
drop trigger table_history_upd;
drop trigger table_history_del;
drop view table_with_history;
-- apply alter tables
CALL usp_ebean_drop_column('table', 'textfield');
CALL usp_ebean_drop_column('table', 'textfield2');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'one_key');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'two_key');
CALL usp_ebean_drop_column('migtest_ckey_parent', 'assoc_id');
@@ -33,6 +38,8 @@ CALL usp_ebean_drop_column('migtest_e_history5', 'test_boolean');
CALL usp_ebean_drop_column('migtest_e_history5_history', 'test_boolean');
CALL usp_ebean_drop_column('migtest_e_softdelete', 'deleted');
CALL usp_ebean_drop_column('migtest_oto_child', 'master_id');
CALL usp_ebean_drop_column('table_history', 'textfield');
CALL usp_ebean_drop_column('table_history', 'textfield2');
-- apply post alter
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
lock tables migtest_e_history2 write;
@@ -58,6 +65,18 @@ create trigger migtest_e_history5_history_del before delete on migtest_e_history
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$$
unlock tables;
create view table_with_history as select * from `table` union all select * from table_history;
lock tables `table` write;
delimiter $$
create trigger table_history_upd before update on `table` for each row begin
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger table_history_del before delete on `table` for each row begin
insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
end$$
unlock tables;
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;
@@ -1,8 +1,8 @@
1835064798, I__create_procs.sql
-1717521141, 1.0__initial.sql
-1234435534, 1.1.sql
369577572, 1.0__initial.sql
-92753611, 1.1.sql
-1097227916, 1.2__dropsFor_1.1.sql
-1972055805, 1.3.sql
379252952, 1.4__dropsFor_1.3.sql
1674664705, 1.3.sql
-1282113429, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -313,6 +314,7 @@ create table table_history(
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
textfield varchar(255),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
@@ -320,13 +322,13 @@ create view table_with_history as select * from "table" union all select * from
delimiter $$
create or replace trigger table_history_upd for "table" before update for each row as
NEW.sys_period_start = greatest(current_timestamp, date_add(OLD.sys_period_start, interval 1 microsecond));
insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "foreign") values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign");
insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "foreign", textfield) values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign", OLD.textfield);
end_trigger;
$$
delimiter $$
create or replace trigger table_history_del for "table" before delete for each row as
insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "foreign") values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign");
insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "foreign", textfield) values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign", OLD.textfield);
end_trigger;
$$
@@ -64,7 +64,9 @@ drop trigger table_history_upd;
drop trigger table_history_del;
drop view table_with_history;
-- apply alter tables
alter table "table" alter column textfield set null;
alter table "table" add column "select" varchar(255);
alter table "table" add column textfield2 varchar(255);
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_parent add column assoc_id integer;
@@ -102,7 +104,9 @@ alter table migtest_e_history6 alter column test_number2 set null;
alter table migtest_e_history6_history alter column test_number2 set null;
alter table migtest_e_softdelete add column deleted boolean default false not null;
alter table migtest_oto_child add column master_id bigint;
alter table table_history alter column textfield set null;
alter table table_history add column "select" varchar(255);
alter table table_history add column textfield2 varchar(255);
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
@@ -208,13 +212,13 @@ create view table_with_history as select * from "table" union all select * from
delimiter $$
create or replace trigger table_history_upd for "table" before update for each row as
NEW.sys_period_start = greatest(current_timestamp, date_add(OLD.sys_period_start, interval 1 microsecond));
insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "select", "foreign") values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "select", "foreign", textfield, textfield2) values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign", OLD.textfield, OLD.textfield2);
end_trigger;
$$
delimiter $$
create or replace trigger table_history_del for "table" before delete for each row as
insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "select", "foreign") values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "select", "foreign", textfield, textfield2) values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign", OLD.textfield, OLD.textfield2);
end_trigger;
$$
@@ -248,3 +252,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on "table" (textfield2);
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
@@ -12,7 +12,12 @@ drop view migtest_e_history2_with_history;
drop trigger migtest_e_history5_history_upd;
drop trigger migtest_e_history5_history_del;
drop view migtest_e_history5_with_history;
drop trigger table_history_upd;
drop trigger table_history_del;
drop view table_with_history;
-- apply alter tables
alter table "table" drop column textfield;
alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -33,6 +38,8 @@ alter table migtest_e_history5 drop column test_boolean;
alter table migtest_e_history5_history drop column test_boolean;
alter table migtest_e_softdelete drop column deleted;
alter table migtest_oto_child drop column master_id;
alter table table_history drop column textfield;
alter table table_history drop column textfield2;
-- apply post alter
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
delimiter $$
@@ -62,6 +69,20 @@ create or replace trigger migtest_e_history5_history_del for migtest_e_history5
end_trigger;
$$
create view table_with_history as select * from "table" union all select * from table_history;
delimiter $$
create or replace trigger table_history_upd for "table" before update for each row as
NEW.sys_period_start = greatest(current_timestamp, date_add(OLD.sys_period_start, interval 1 microsecond));
insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "select", "foreign") values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
end_trigger;
$$
delimiter $$
create or replace trigger table_history_del for "table" before delete for each row as
insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "select", "foreign") values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
end_trigger;
$$
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;
@@ -1,7 +1,7 @@
-355978970, 1.0__initial.sql
-667611059, 1.1.sql
390216918, 1.0__initial.sql
-2079708895, 1.1.sql
1530685455, 1.2__dropsFor_1.1.sql
1263834751, 1.3.sql
-1189704269, 1.4__dropsFor_1.3.sql
73983167, 1.3.sql
-1118858496, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar2(255),
"varchar" varchar2(255),
"foreign" varchar2(255),
textfield varchar2(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -91,7 +91,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
alter table "table" modify textfield null;
alter table "table" add "select" varchar2(255);
alter table "table" add textfield2 varchar2(255);
alter table migtest_ckey_detail add one_key number(10);
alter table migtest_ckey_detail add two_key varchar2(127);
alter table migtest_ckey_parent add assoc_id number(10);
@@ -164,3 +166,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on "table" (textfield2);
@@ -88,6 +88,7 @@ end;
$$;
drop index ix_migtest_e_basic_indextest3;
drop index ix_migtest_e_basic_indextest6;
drop index ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar2(255) not null,
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
alter table "table" drop column textfield;
alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -1,8 +1,8 @@
1374133214, 1.0__initial.sql
-2091161947, 1.1.sql
1757923548, 1.0__initial.sql
740264587, 1.1.sql
930172034, 1.2__dropsFor_1.1.sql
-1621367223, 1.3.sql
663051206, 1.4__dropsFor_1.3.sql
-1896525025, 1.3.sql
2037899598, 1.4__dropsFor_1.3.sql
1357801733, R__oracle_only_views.sql
561281075, R__order_views.sql
@@ -174,6 +174,7 @@ create table "table" (
"to" varchar2(255),
"varchar" varchar2(255),
"foreign" varchar2(255),
textfield varchar2(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -92,7 +92,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
alter table "table" modify textfield null;
alter table "table" add "select" varchar2(255);
alter table "table" add textfield2 varchar2(255);
alter table migtest_ckey_detail add one_key number(10);
alter table migtest_ckey_detail add two_key varchar2(127);
alter table migtest_ckey_parent add assoc_id number(10);
@@ -165,3 +167,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on "table" (textfield2);
@@ -88,6 +88,7 @@ end;
$$;
drop index ix_migtest_e_basic_indextest3;
drop index ix_migtest_e_basic_indextest6;
drop index ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar2(255) not null,
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
alter table "table" drop column textfield;
alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -1,8 +1,8 @@
1070168506, 1.0__initial.sql
-1116696749, 1.1.sql
-1422254768, 1.0__initial.sql
-123689547, 1.1.sql
930172034, 1.2__dropsFor_1.1.sql
-144959080, 1.3.sql
663051206, 1.4__dropsFor_1.3.sql
1967473644, 1.3.sql
2037899598, 1.4__dropsFor_1.3.sql
1357801733, R__oracle_only_views.sql
561281075, R__order_views.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -329,11 +330,11 @@ begin
lowerTs = lower(OLD.sys_period);
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
if (TG_OP = 'UPDATE') then
insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign");
insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign", textfield) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign", OLD.textfield);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign");
insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign", textfield) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign", OLD.textfield);
return old;
end if;
end;
@@ -75,7 +75,9 @@ drop function if exists table_history_version();
drop view table_with_history;
-- apply alter tables
alter table "table" alter column textfield drop not null;
alter table "table" add column "select" varchar(255);
alter table "table" add column textfield2 varchar(255);
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_parent add column assoc_id integer;
@@ -112,7 +114,9 @@ alter table migtest_e_history6 alter column test_number2 drop not null;
alter table migtest_e_history6_history alter column test_number2 drop not null;
alter table migtest_e_softdelete add column deleted boolean default false not null;
alter table migtest_oto_child add column master_id bigint;
alter table table_history alter column textfield drop not null;
alter table table_history add column "select" varchar(255);
alter table table_history add column textfield2 varchar(255);
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
@@ -275,11 +279,11 @@ begin
lowerTs = lower(OLD.sys_period);
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
if (TG_OP = 'UPDATE') then
insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign", textfield, textfield2) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign", OLD.textfield, OLD.textfield2);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign", textfield, textfield2) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign", OLD.textfield, OLD.textfield2);
return old;
end if;
end;
@@ -319,4 +323,5 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index if not exists ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index if not exists ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index if not exists ix_table_textfield2 on "table" (textfield2);
create index if not exists ix_migtest_oto_child_name on migtest_oto_child (name);
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
@@ -15,7 +15,13 @@ drop trigger if exists migtest_e_history5_history_upd on migtest_e_history5 casc
drop function if exists migtest_e_history5_history_version();
drop view migtest_e_history5_with_history;
drop trigger if exists table_history_upd on "table" cascade;
drop function if exists table_history_version();
drop view table_with_history;
-- apply alter tables
alter table "table" drop column textfield;
alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -35,6 +41,8 @@ alter table migtest_e_history5 drop column test_boolean;
alter table migtest_e_history5_history drop column test_boolean;
alter table migtest_e_softdelete drop column deleted;
alter table migtest_oto_child drop column master_id;
alter table table_history drop column textfield;
alter table table_history drop column textfield2;
-- apply post alter
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
create or replace function migtest_e_history2_history_version() returns trigger as $$
@@ -82,6 +90,29 @@ create trigger migtest_e_history5_history_upd
before update or delete on migtest_e_history5
for each row execute procedure migtest_e_history5_history_version();
create view table_with_history as select * from "table" union all select * from table_history;
create or replace function table_history_version() returns trigger as $$
declare
lowerTs timestamptz;
upperTs timestamptz;
begin
lowerTs = lower(OLD.sys_period);
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
if (TG_OP = 'UPDATE') then
insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger table_history_upd
before update or delete on "table"
for each row execute procedure table_history_version();
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;
@@ -1,8 +1,8 @@
2094204208, 1.0__initial.sql
-1092950076, 1.1.sql
-769462329, 1.0__initial.sql
409812555, 1.1.sql
-261111052, 1.2__dropsFor_1.1.sql
1335621453, 1.3.sql
1729345905, 1.4__dropsFor_1.3.sql
1214144459, 1.3.sql
-709144111, 1.4__dropsFor_1.3.sql
783227075, R__multi_comments.sql
561281075, R__order_views.sql
283077354, R__pg_indexes.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -329,11 +330,11 @@ begin
lowerTs = lower(OLD.sys_period);
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
if (TG_OP = 'UPDATE') then
insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign");
insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign", textfield) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign", OLD.textfield);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign");
insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign", textfield) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign", OLD.textfield);
return old;
end if;
end;
@@ -75,7 +75,9 @@ drop function if exists table_history_version();
drop view table_with_history;
-- apply alter tables
alter table "table" alter column textfield drop not null;
alter table "table" add column "select" varchar(255);
alter table "table" add column textfield2 varchar(255);
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_parent add column assoc_id integer;
@@ -112,7 +114,9 @@ alter table migtest_e_history6 alter column test_number2 drop not null;
alter table migtest_e_history6_history alter column test_number2 drop not null;
alter table migtest_e_softdelete add column deleted boolean default false not null;
alter table migtest_oto_child add column master_id bigint;
alter table table_history alter column textfield drop not null;
alter table table_history add column "select" varchar(255);
alter table table_history add column textfield2 varchar(255);
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
@@ -275,11 +279,11 @@ begin
lowerTs = lower(OLD.sys_period);
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
if (TG_OP = 'UPDATE') then
insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign", textfield, textfield2) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign", OLD.textfield, OLD.textfield2);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign", textfield, textfield2) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign", OLD.textfield, OLD.textfield2);
return old;
end if;
end;
@@ -319,4 +323,5 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index if not exists ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index if not exists ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index if not exists ix_table_textfield2 on "table" (textfield2);
create index if not exists ix_migtest_oto_child_name on migtest_oto_child (name);
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
@@ -15,7 +15,13 @@ drop trigger if exists migtest_e_history5_history_upd on migtest_e_history5 casc
drop function if exists migtest_e_history5_history_version();
drop view migtest_e_history5_with_history;
drop trigger if exists table_history_upd on "table" cascade;
drop function if exists table_history_version();
drop view table_with_history;
-- apply alter tables
alter table "table" drop column textfield;
alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -35,6 +41,8 @@ alter table migtest_e_history5 drop column test_boolean;
alter table migtest_e_history5_history drop column test_boolean;
alter table migtest_e_softdelete drop column deleted;
alter table migtest_oto_child drop column master_id;
alter table table_history drop column textfield;
alter table table_history drop column textfield2;
-- apply post alter
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
create or replace function migtest_e_history2_history_version() returns trigger as $$
@@ -82,6 +90,29 @@ create trigger migtest_e_history5_history_upd
before update or delete on migtest_e_history5
for each row execute procedure migtest_e_history5_history_version();
create view table_with_history as select * from "table" union all select * from table_history;
create or replace function table_history_version() returns trigger as $$
declare
lowerTs timestamptz;
upperTs timestamptz;
begin
lowerTs = lower(OLD.sys_period);
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
if (TG_OP = 'UPDATE') then
insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger table_history_upd
before update or delete on "table"
for each row execute procedure table_history_version();
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;
@@ -1,8 +1,8 @@
-231429368, 1.0__initial.sql
1978065929, 1.1.sql
-309942302, 1.0__initial.sql
2116598611, 1.1.sql
-261111052, 1.2__dropsFor_1.1.sql
-893728811, 1.3.sql
1729345905, 1.4__dropsFor_1.3.sql
-388526579, 1.3.sql
-709144111, 1.4__dropsFor_1.3.sql
783227075, R__multi_comments.sql
561281075, R__order_views.sql
283077354, R__pg_indexes.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -46,7 +46,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
alter table "table" alter column textfield set null;
alter table "table" add column "select" varchar(255);
alter table "table" add column textfield2 varchar(255);
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_parent add column assoc_id integer;
@@ -119,3 +121,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
create index ix_table_textfield2 on "table" (textfield2);

Some files were not shown because too many files have changed in this diff Show More