Reference scripts

This commit is contained in:
Roland Praml
2022-03-16 15:12:12 +01:00
parent d37bf4634a
commit 4bd678fc3c
226 changed files with 15784 additions and 3287 deletions
@@ -0,0 +1,312 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer generated by default as identity not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer generated by default as identity not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer generated by default as identity not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date timestamp,
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field boolean default true not null,
new_boolean_field2 boolean default true not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer generated by default as identity not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer generated by default as identity not null,
test_string bigint,
constraint pk_migtest_e_history primary key (id)
);
comment on table migtest_e_history is 'We have history now';
comment on column migtest_e_history.test_string is 'Column altered to long now';
create table migtest_e_history2 (
id integer generated by default as identity not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer generated by default as identity not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer generated by default as identity not null,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer generated by default as identity not null,
test_number integer,
test_boolean boolean default false not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer generated by default as identity not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer generated by default as identity not null,
test_string varchar(255),
deleted boolean default false not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
) in TESTTS index in TESTTS long in TESTTS;
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
) in TESTTS index in TESTTS long in TESTTS;
create table migtest_mtm_m (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
) in TSMASTER index in TSMASTER long in TSMASTER;
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
) in TSMASTER index in TSMASTER long in TSMASTER;
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
) in TSMASTER index in TSMASTER long in TSMASTER;
create table migtest_oto_child (
id integer generated by default as identity not null,
name varchar(255),
master_id bigint,
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- apply alter tables
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_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_description on migtest_e_basic(description) exclude null keys;
create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) exclude null keys;
create unique index uq_migtest_e_basic_name on migtest_e_basic(name) exclude null keys;
create unique index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) exclude null keys;
create unique index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) exclude null keys;
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;
create table migtest_e_history2_history (
id integer not null,
test_string varchar(255) not null,
test_string2 varchar(255),
test_string3 varchar(255) not null,
new_column varchar(20),
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 bigint,
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,
test_boolean boolean 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_history5 add versioning use history table migtest_e_history5_history;
create table migtest_e_history6_history (
id integer not null,
test_number1 integer not null,
test_number2 integer,
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;
create unique index uq_migtest_oto_child_master_id on migtest_oto_child(master_id) exclude null keys;
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,306 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer generated by default as identity not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer generated by default as identity not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer generated by default as identity not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date timestamp,
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field boolean default true not null,
new_boolean_field2 boolean default true not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer generated by default as identity not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer generated by default as identity not null,
test_string bigint,
constraint pk_migtest_e_history primary key (id)
);
comment on table migtest_e_history is 'We have history now';
comment on column migtest_e_history.test_string is 'Column altered to long now';
create table migtest_e_history2 (
id integer generated by default as identity not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer generated by default as identity not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer generated by default as identity not null,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer generated by default as identity not null,
test_number integer,
test_boolean boolean default false not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer generated by default as identity not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer generated by default as identity not null,
test_string varchar(255),
deleted boolean default false not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
create table migtest_oto_child (
id integer generated by default as identity not null,
name varchar(255),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- apply alter tables
alter table migtest_e_history add column sys_period_start timestamp default now();
alter table migtest_e_history add column sys_period_end timestamp;
alter table migtest_e_history2 add column sys_period_start timestamp default now();
alter table migtest_e_history2 add column sys_period_end timestamp;
alter table migtest_e_history3 add column sys_period_start timestamp default now();
alter table migtest_e_history3 add column sys_period_end timestamp;
alter table migtest_e_history4 add column sys_period_start timestamp default now();
alter table migtest_e_history4 add column sys_period_end timestamp;
alter table migtest_e_history5 add column sys_period_start timestamp default now();
alter table migtest_e_history5 add column sys_period_end timestamp;
alter table migtest_e_history6 add column sys_period_start timestamp default now();
alter table migtest_e_history6 add column sys_period_end timestamp;
-- apply post alter
create table migtest_e_history_history(
id integer,
test_string bigint,
sys_period_start timestamp,
sys_period_end timestamp
);
create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history;
create trigger migtest_e_history_history_upd before update,delete on migtest_e_history for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create table migtest_e_history2_history(
id integer,
test_string varchar(255),
test_string2 varchar(255),
test_string3 varchar(255),
new_column varchar(20),
sys_period_start timestamp,
sys_period_end timestamp
);
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.config.dbplatform.h2.H2HistoryTrigger";
create table migtest_e_history3_history(
id integer,
test_string varchar(255),
sys_period_start timestamp,
sys_period_end timestamp
);
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create table migtest_e_history4_history(
id integer,
test_number bigint,
sys_period_start timestamp,
sys_period_end timestamp
);
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create table migtest_e_history5_history(
id integer,
test_number integer,
test_boolean boolean,
sys_period_start timestamp,
sys_period_end timestamp
);
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.config.dbplatform.h2.H2HistoryTrigger";
create table migtest_e_history6_history(
id integer,
test_number1 integer,
test_number2 integer,
sys_period_start timestamp,
sys_period_end timestamp
);
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
create trigger migtest_e_history6_history_upd before update,delete on migtest_e_history6 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -9,6 +9,8 @@ create column table migtest_ckey_assoc (
create column table migtest_ckey_detail (
id integer generated by default as identity not null,
something nvarchar(255),
one_key integer,
two_key nvarchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
@@ -16,6 +18,7 @@ create column table migtest_ckey_parent (
one_key integer not null,
two_key nvarchar(127) not null,
name nvarchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
@@ -56,33 +59,36 @@ create column table migtest_fk_set_null (
create column table migtest_e_basic (
id integer generated by default as identity not null,
status nvarchar(1),
status2 nvarchar(1) default 'N' not null,
status nvarchar(1) default 'A' not null,
status2 nvarchar(127),
name nvarchar(127),
description nvarchar(127),
description_file blob,
some_date timestamp,
old_boolean boolean default false not null,
old_boolean2 boolean,
eref_id integer,
new_string_field nvarchar(255) default 'foo''bar' not null,
new_boolean_field boolean default true not null,
new_boolean_field2 boolean default true not null,
indextest1 nvarchar(127),
indextest2 nvarchar(127),
indextest3 nvarchar(127),
indextest4 nvarchar(127),
indextest5 nvarchar(127),
indextest6 nvarchar(127),
user_id integer default 23 not null,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I')),
constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')),
constraint uq_migtest_e_basic_indextest2 unique (indextest2),
constraint uq_migtest_e_basic_indextest6 unique (indextest6),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create column table migtest_e_enum (
id integer generated by default as identity not null,
test_status nvarchar(1),
constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')),
constraint pk_migtest_e_enum primary key (id)
);
@@ -91,12 +97,15 @@ create column table migtest_e_history (
test_string bigint,
constraint pk_migtest_e_history primary key (id)
);
comment on table migtest_e_history is 'We have history now';
comment on column migtest_e_history.test_string is 'Column altered to long now';
create column table migtest_e_history2 (
id integer generated by default as identity not null,
test_string nvarchar(255),
obsolete_string1 nvarchar(255),
obsolete_string2 nvarchar(255),
test_string nvarchar(255) default 'unknown' not null,
test_string2 nvarchar(255),
test_string3 nvarchar(255) default 'unknown' not null,
new_column nvarchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
@@ -108,51 +117,70 @@ create column table migtest_e_history3 (
create column table migtest_e_history4 (
id integer generated by default as identity not null,
test_number integer,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create column table migtest_e_history5 (
id integer generated by default as identity not null,
test_number integer,
test_boolean boolean default false not null,
constraint pk_migtest_e_history5 primary key (id)
);
create column table migtest_e_history6 (
id integer generated by default as identity not null,
test_number1 integer,
test_number2 integer default 7 not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create column table migtest_e_ref (
id integer generated by default as identity not null,
name nvarchar(127) not null,
constraint uq_migtest_e_ref_name unique (name),
constraint pk_migtest_e_ref primary key (id)
);
create column table migtest_e_softdelete (
id integer generated by default as identity not null,
test_string nvarchar(255),
deleted boolean default false not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create column table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create column table migtest_mtm_c (
id integer generated by default as identity not null,
name nvarchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create column table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create column table migtest_mtm_m (
id bigint generated by default as identity not null,
name nvarchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create column table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create column table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value nvarchar(255) not null
);
create column table migtest_oto_child (
id integer generated by default as identity not null,
name nvarchar(255),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
@@ -162,22 +190,26 @@ create column table migtest_oto_master (
constraint pk_migtest_oto_master primary key (id)
);
-- explicit index "ix_migtest_e_basic_indextest1" for single column "indextest1" of table "migtest_e_basic" is not necessary;
-- explicit index "ix_migtest_e_basic_indextest5" for single column "indextest5" of table "migtest_e_basic" is not necessary;
-- explicit index "ix_migtest_fk_cascade_one_id" for single column "one_id" of table "migtest_fk_cascade" is not necessary;
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;
-- explicit index "ix_migtest_fk_set_null_one_id" for single column "one_id" of table "migtest_fk_set_null" is not necessary;
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict;
-- explicit index "ix_migtest_e_basic_eref_id" for single column "eref_id" of table "migtest_e_basic" is not necessary;
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
-- apply alter tables
-- apply post alter
create column table migtest_e_history_history (
id integer,
test_string bigint,
sys_period_start timestamp,
sys_period_end timestamp
);
alter table migtest_e_history add (
sys_period_start TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW START,
sys_period_end TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW END
);
alter table migtest_e_history add period for system_time(sys_period_start,sys_period_end);
alter table migtest_e_history add system versioning history table migtest_e_history_history;
create column table migtest_e_history2_history (
id integer,
test_string nvarchar(255),
obsolete_string1 nvarchar(255),
obsolete_string2 nvarchar(255),
test_string nvarchar(255) default 'unknown' not null,
test_string2 nvarchar(255),
test_string3 nvarchar(255) default 'unknown' not null,
new_column nvarchar(20),
sys_period_start timestamp,
sys_period_end timestamp
);
@@ -201,7 +233,7 @@ alter table migtest_e_history3 add period for system_time(sys_period_start,sys_p
alter table migtest_e_history3 add system versioning history table migtest_e_history3_history;
create column table migtest_e_history4_history (
id integer,
test_number integer,
test_number bigint,
sys_period_start timestamp,
sys_period_end timestamp
);
@@ -214,6 +246,7 @@ alter table migtest_e_history4 add system versioning history table migtest_e_his
create column table migtest_e_history5_history (
id integer,
test_number integer,
test_boolean boolean default false not null,
sys_period_start timestamp,
sys_period_end timestamp
);
@@ -225,8 +258,8 @@ alter table migtest_e_history5 add period for system_time(sys_period_start,sys_p
alter table migtest_e_history5 add system versioning history table migtest_e_history5_history;
create column table migtest_e_history6_history (
id integer,
test_number1 integer,
test_number2 integer default 7 not null,
test_number1 integer default 42 not null,
test_number2 integer,
sys_period_start timestamp,
sys_period_end timestamp
);
@@ -236,3 +269,44 @@ alter table migtest_e_history6 add (
);
alter table migtest_e_history6 add period for system_time(sys_period_start,sys_period_end);
alter table migtest_e_history6 add system versioning history table migtest_e_history6_history;
-- foreign keys and indices
create inverted hash index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
-- explicit index "ix_migtest_ckey_parent_assoc_id" for single column "assoc_id" of table "migtest_ckey_parent" is not necessary;
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_fk_cascade_one_id" for single column "one_id" of table "migtest_fk_cascade" is not necessary;
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_fk_none_one_id" for single column "one_id" of table "migtest_fk_none" is not necessary;
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_fk_none_via_join_one_id" for single column "one_id" of table "migtest_fk_none_via_join" is not necessary;
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_fk_set_null_one_id" for single column "one_id" of table "migtest_fk_set_null" is not necessary;
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_e_basic_user_id" for single column "user_id" of table "migtest_e_basic" is not necessary;
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c" for single column "migtest_mtm_c_id" of table "migtest_mtm_c_migtest_mtm_m" is not necessary;
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;
-- explicit index "ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m" for single column "migtest_mtm_m_id" of table "migtest_mtm_c_migtest_mtm_m" is not necessary;
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m" for single column "migtest_mtm_m_id" of table "migtest_mtm_m_migtest_mtm_c" is not necessary;
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c" for single column "migtest_mtm_c_id" of table "migtest_mtm_m_migtest_mtm_c" is not necessary;
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id" for single column "migtest_mtm_m_id" of table "migtest_mtm_m_phone_numbers" is not necessary;
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
-- 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;
@@ -0,0 +1,233 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer generated by default as identity (start with 1) not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer generated by default as identity (start with 1) not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint generated by default as identity (start with 1) not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint generated by default as identity (start with 1) not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint generated by default as identity (start with 1) not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint generated by default as identity (start with 1) not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint generated by default as identity (start with 1) not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint generated by default as identity (start with 1) not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer generated by default as identity (start with 1) not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date timestamp,
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field boolean default true not null,
new_boolean_field2 boolean default true not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer generated by default as identity (start with 1) not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer generated by default as identity (start with 1) not null,
test_string bigint,
constraint pk_migtest_e_history primary key (id)
);
comment on table migtest_e_history is 'We have history now';
comment on column migtest_e_history.test_string is 'Column altered to long now';
create table migtest_e_history2 (
id integer generated by default as identity (start with 1) not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer generated by default as identity (start with 1) not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer generated by default as identity (start with 1) not null,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer generated by default as identity (start with 1) not null,
test_number integer,
test_boolean boolean default false not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer generated by default as identity (start with 1) not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer generated by default as identity (start with 1) not null,
test_string varchar(255),
deleted boolean default false not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer generated by default as identity (start with 1) not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer generated by default as identity (start with 1) not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id bigint generated by default as identity (start with 1) not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
create table migtest_oto_child (
id integer generated by default as identity (start with 1) not null,
name varchar(255),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint generated by default as identity (start with 1) not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,236 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer auto_increment not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer auto_increment not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint auto_increment not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint auto_increment not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer auto_increment not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date datetime(6),
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field tinyint(1) default 1 not null,
new_boolean_field2 tinyint(1) default 1 not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer auto_increment not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer auto_increment not null,
test_string bigint comment 'Column altered to long now',
constraint pk_migtest_e_history primary key (id)
) comment='We have history now';
create table migtest_e_history2 (
id integer auto_increment not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer auto_increment not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer auto_increment not null,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer auto_increment not null,
test_number integer,
test_boolean tinyint(1) default 0 not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer auto_increment not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer auto_increment not null,
test_string varchar(255),
deleted tinyint(1) default 0 not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer auto_increment not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer auto_increment not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id bigint auto_increment not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
create table migtest_oto_child (
id integer auto_increment not null,
name varchar(255),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint auto_increment not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- apply alter tables
alter table migtest_e_history add system versioning;
alter table migtest_e_history2 add system versioning;
alter table migtest_e_history3 add system versioning;
alter table migtest_e_history4 add system versioning;
alter table migtest_e_history5 add system versioning;
alter table migtest_e_history6 add system versioning;
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,362 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer auto_increment not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer auto_increment not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint auto_increment not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint auto_increment not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer auto_increment not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date datetime(6),
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field tinyint(1) default 1 not null,
new_boolean_field2 tinyint(1) default 1 not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer auto_increment not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer auto_increment not null,
test_string bigint comment 'Column altered to long now',
constraint pk_migtest_e_history primary key (id)
) comment='We have history now';
create table migtest_e_history2 (
id integer auto_increment not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer auto_increment not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer auto_increment not null,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer auto_increment not null,
test_number integer,
test_boolean tinyint(1) default 0 not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer auto_increment not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer auto_increment not null,
test_string varchar(255),
deleted tinyint(1) default 0 not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer auto_increment not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer auto_increment not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id bigint auto_increment not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
create table migtest_oto_child (
id integer auto_increment not null,
name varchar(255),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint auto_increment not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- apply alter tables
alter table migtest_e_history add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history add column sys_period_end datetime(6);
alter table migtest_e_history2 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history2 add column sys_period_end datetime(6);
alter table migtest_e_history3 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history3 add column sys_period_end datetime(6);
alter table migtest_e_history4 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history4 add column sys_period_end datetime(6);
alter table migtest_e_history5 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history5 add column sys_period_end datetime(6);
alter table migtest_e_history6 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history6 add column sys_period_end datetime(6);
-- apply post alter
create table migtest_e_history_history(
id integer,
test_string bigint,
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history;
lock tables migtest_e_history write;
delimiter $$
create trigger migtest_e_history_history_upd before update on migtest_e_history for each row begin
insert into migtest_e_history_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history_history_del before delete on migtest_e_history for each row begin
insert into migtest_e_history_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
end$$
unlock tables;
create table migtest_e_history2_history(
id integer,
test_string varchar(255),
test_string2 varchar(255),
test_string3 varchar(255),
new_column varchar(20),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
lock tables migtest_e_history2 write;
delimiter $$
create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, new_column) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, new_column) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
end$$
unlock tables;
create table migtest_e_history3_history(
id integer,
test_string varchar(255),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
lock tables migtest_e_history3 write;
delimiter $$
create trigger migtest_e_history3_history_upd before update on migtest_e_history3 for each row begin
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id) values (OLD.sys_period_start, now(6),OLD.id);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history3_history_del before delete on migtest_e_history3 for each row begin
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id) values (OLD.sys_period_start, now(6),OLD.id);
end$$
unlock tables;
create table migtest_e_history4_history(
id integer,
test_number bigint,
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
lock tables migtest_e_history4 write;
delimiter $$
create trigger migtest_e_history4_history_upd before update on migtest_e_history4 for each row begin
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history4_history_del before delete on migtest_e_history4 for each row begin
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
end$$
unlock tables;
create table migtest_e_history5_history(
id integer,
test_number integer,
test_boolean tinyint(1),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
lock tables migtest_e_history5 write;
delimiter $$
create trigger migtest_e_history5_history_upd before update on migtest_e_history5 for each row begin
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number, test_boolean) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number, OLD.test_boolean);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history5_history_del before delete on migtest_e_history5 for each row begin
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number, test_boolean) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number, OLD.test_boolean);
end$$
unlock tables;
create table migtest_e_history6_history(
id integer,
test_number1 integer,
test_number2 integer,
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
lock tables migtest_e_history6 write;
delimiter $$
create trigger migtest_e_history6_history_upd before update on migtest_e_history6 for each row begin
insert into migtest_e_history6_history (sys_period_start,sys_period_end,id, test_number1, test_number2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number1, OLD.test_number2);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history6_history_del before delete on migtest_e_history6 for each row begin
insert into migtest_e_history6_history (sys_period_start,sys_period_end,id, test_number1, test_number2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number1, OLD.test_number2);
end$$
unlock tables;
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -9,6 +9,8 @@ create table migtest_ckey_assoc (
create table migtest_ckey_detail (
id integer auto_increment not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
@@ -16,6 +18,7 @@ create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
@@ -56,24 +59,28 @@ create table migtest_fk_set_null (
create table migtest_e_basic (
id integer auto_increment not null,
status varchar(1),
status2 varchar(1) default 'N' not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
description_file longblob,
some_date datetime,
old_boolean tinyint(1) default 0 not null,
old_boolean2 tinyint(1),
eref_id integer,
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field tinyint(1) default 1 not null,
new_boolean_field2 tinyint(1) default 1 not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
user_id integer default 23 not null,
constraint uq_migtest_e_basic_indextest2 unique (indextest2),
constraint uq_migtest_e_basic_indextest6 unique (indextest6),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
@@ -85,15 +92,16 @@ create table migtest_e_enum (
create table migtest_e_history (
id integer auto_increment not null,
test_string bigint,
test_string bigint comment 'Column altered to long now',
constraint pk_migtest_e_history primary key (id)
);
) comment='We have history now';
create table migtest_e_history2 (
id integer auto_increment not null,
test_string varchar(255),
obsolete_string1 varchar(255),
obsolete_string2 varchar(255),
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
@@ -105,89 +113,134 @@ create table migtest_e_history3 (
create table migtest_e_history4 (
id integer auto_increment not null,
test_number integer,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer auto_increment not null,
test_number integer,
test_boolean tinyint(1) default 0 not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer auto_increment not null,
test_number1 integer,
test_number2 integer default 7 not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_ref (
id integer auto_increment not null,
name varchar(127) not null,
constraint uq_migtest_e_ref_name unique (name),
constraint pk_migtest_e_ref primary key (id)
);
create table migtest_e_softdelete (
id integer auto_increment not null,
test_string varchar(255),
deleted tinyint(1) default 0 not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer auto_increment not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer auto_increment not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id bigint auto_increment not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
create table migtest_oto_child (
id integer auto_increment not null,
name varchar(255),
constraint uq_m12_otoc72 unique (name),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint auto_increment not null,
name varchar(255),
constraint uq_migtest_oto_master_name unique (name),
constraint pk_migtest_oto_master primary key (id)
);
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
create index ix_m12_otoc72 on migtest_oto_child (name);
create index ix_migtest_oto_master_name on migtest_oto_master (name);
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict;
create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
-- apply alter tables
alter table migtest_e_history add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history add column sys_period_end datetime(6);
alter table migtest_e_history2 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history2 add column sys_period_end datetime(6);
alter table migtest_e_history3 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history3 add column sys_period_end datetime(6);
alter table migtest_e_history4 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history4 add column sys_period_end datetime(6);
alter table migtest_e_history5 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history5 add column sys_period_end datetime(6);
alter table migtest_e_history6 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history6 add column sys_period_end datetime(6);
-- apply post alter
create table migtest_e_history_history(
id integer,
test_string bigint,
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history;
lock tables migtest_e_history write;
delimiter $$
create trigger migtest_e_history_history_upd before update on migtest_e_history for each row begin
insert into migtest_e_history_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history_history_del before delete on migtest_e_history for each row begin
insert into migtest_e_history_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
end$$
unlock tables;
create table migtest_e_history2_history(
id integer,
test_string varchar(255),
obsolete_string1 varchar(255),
obsolete_string2 varchar(255),
test_string2 varchar(255),
test_string3 varchar(255),
new_column varchar(20),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
lock tables migtest_e_history2 write;
delimiter $$
create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, new_column) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, new_column) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
end$$
unlock tables;
alter table migtest_e_history3 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history3 add column sys_period_end datetime(6);
create table migtest_e_history3_history(
id integer,
test_string varchar(255),
@@ -195,56 +248,26 @@ create table migtest_e_history3_history(
sys_period_end datetime(6)
);
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
alter table migtest_e_history4 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history4 add column sys_period_end datetime(6);
create table migtest_e_history4_history(
id integer,
test_number integer,
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
alter table migtest_e_history5 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history5 add column sys_period_end datetime(6);
create table migtest_e_history5_history(
id integer,
test_number integer,
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
alter table migtest_e_history6 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history6 add column sys_period_end datetime(6);
create table migtest_e_history6_history(
id integer,
test_number1 integer,
test_number2 integer,
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
delimiter $$
create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, obsolete_string2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.obsolete_string2);
end$$
lock tables migtest_e_history3 write;
delimiter $$
create trigger migtest_e_history3_history_upd before update on migtest_e_history3 for each row begin
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id) values (OLD.sys_period_start, now(6),OLD.id);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history3_history_del before delete on migtest_e_history3 for each row begin
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id) values (OLD.sys_period_start, now(6),OLD.id);
end$$
unlock tables;
create table migtest_e_history4_history(
id integer,
test_number bigint,
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
lock tables migtest_e_history4 write;
delimiter $$
create trigger migtest_e_history4_history_upd before update on migtest_e_history4 for each row begin
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
@@ -254,15 +277,37 @@ delimiter $$
create trigger migtest_e_history4_history_del before delete on migtest_e_history4 for each row begin
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
end$$
unlock tables;
create table migtest_e_history5_history(
id integer,
test_number integer,
test_boolean tinyint(1),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
lock tables migtest_e_history5 write;
delimiter $$
create trigger migtest_e_history5_history_upd before update on migtest_e_history5 for each row begin
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number, test_boolean) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number, OLD.test_boolean);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history5_history_del before delete on migtest_e_history5 for each row begin
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number, test_boolean) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number, OLD.test_boolean);
end$$
unlock tables;
create table migtest_e_history6_history(
id integer,
test_number1 integer,
test_number2 integer,
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
lock tables migtest_e_history6 write;
delimiter $$
create trigger migtest_e_history6_history_upd before update on migtest_e_history6 for each row begin
insert into migtest_e_history6_history (sys_period_start,sys_period_end,id, test_number1, test_number2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number1, OLD.test_number2);
@@ -272,3 +317,46 @@ delimiter $$
create trigger migtest_e_history6_history_del before delete on migtest_e_history6 for each row begin
insert into migtest_e_history6_history (sys_period_start,sys_period_end,id, test_number1, test_number2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number1, OLD.test_number2);
end$$
unlock tables;
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,233 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id number(10) generated by default as identity not null,
assoc_one varchar2(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id number(10) generated by default as identity not null,
something varchar2(255),
one_key number(10),
two_key varchar2(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key number(10) not null,
two_key varchar2(127) not null,
name varchar2(255),
assoc_id number(10),
version number(10) not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id number(19) generated by default as identity not null,
one_id number(19),
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id number(19) generated by default as identity not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id number(19) generated by default as identity not null,
one_id number(19),
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id number(19) generated by default as identity not null,
one_id number(19),
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id number(19) generated by default as identity not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id number(19) generated by default as identity not null,
one_id number(19),
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id number(10) generated by default as identity not null,
status varchar2(1) default 'A' not null,
status2 varchar2(127),
name varchar2(127),
description varchar2(127),
some_date timestamp,
new_string_field varchar2(255) default 'foo''bar' not null,
new_boolean_field number(1) default 1 not null,
new_boolean_field2 number(1) default 1 not null,
indextest1 varchar2(127),
indextest2 varchar2(127),
indextest3 varchar2(127),
indextest4 varchar2(127),
indextest5 varchar2(127),
indextest6 varchar2(127),
progress number(10) default 0 not null,
new_integer number(10) default 42 not null,
user_id number(10),
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id number(10) generated by default as identity not null,
test_status varchar2(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id number(10) generated by default as identity not null,
test_string number(19),
constraint pk_migtest_e_history primary key (id)
);
comment on table migtest_e_history is 'We have history now';
comment on column migtest_e_history.test_string is 'Column altered to long now';
create table migtest_e_history2 (
id number(10) generated by default as identity not null,
test_string varchar2(255) default 'unknown' not null,
test_string2 varchar2(255),
test_string3 varchar2(255) default 'unknown' not null,
new_column varchar2(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id number(10) generated by default as identity not null,
test_string varchar2(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id number(10) generated by default as identity not null,
test_number number(19),
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id number(10) generated by default as identity not null,
test_number number(10),
test_boolean number(1) default 0 not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id number(10) generated by default as identity not null,
test_number1 number(10) default 42 not null,
test_number2 number(10),
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id number(10) generated by default as identity not null,
test_string varchar2(255),
deleted number(1) default 0 not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id number(10) generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id number(10) generated by default as identity not null,
name varchar2(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id number(10) not null,
migtest_mtm_m_id number(19) not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id number(19) generated by default as identity not null,
name varchar2(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id number(19) not null,
migtest_mtm_c_id number(10) not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id number(19) not null,
value varchar2(255) not null
);
create table migtest_oto_child (
id number(10) generated by default as identity not null,
name varchar2(255),
master_id number(19),
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id number(19) generated by default as identity not null,
name varchar2(255),
constraint pk_migtest_oto_master primary key (id)
);
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key);
create index ix_mgtst_cky_prnt_ssc_d on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_mgtst_cky_prnt_ssc_d foreign key (assoc_id) references migtest_ckey_assoc (id);
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id);
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id);
create index ix_mgtst_fk_nn_v_jn_n_d on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_mgtst_fk_nn_v_jn_n_d foreign key (one_id) references migtest_fk_one (id);
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id);
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id);
create index ix_mgtst_mtm_c_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_mtm_c_mgtst_mt_93awga foreign key (migtest_mtm_c_id) references migtest_mtm_c (id);
create index ix_mgtst_mtm_c_mgtst_mt_3ug4ou on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_mgtst_mtm_c_mgtst_mt_93awgk foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
create index ix_mgtst_mtm_m_mgtst_mt_b7nbcu on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mtm_m_mgtst_mt_ggi34k foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
create index ix_mgtst_mtm_m_mgtst_mt_b7nbck on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mtm_m_mgtst_mt_ggi34a foreign key (migtest_mtm_c_id) references migtest_mtm_c (id);
create index ix_mgtst_mtm_m_phn_nmbr_do9ma3 on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_mgtst_mtm_m_phn_nmbr_s8neid foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id);
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,392 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer generated by default as identity not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer generated by default as identity not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer generated by default as identity not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date timestamptz,
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field boolean default true not null,
new_boolean_field2 boolean default true not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer generated by default as identity not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer generated by default as identity not null,
test_string bigint,
constraint pk_migtest_e_history primary key (id)
);
comment on table migtest_e_history is 'We have history now';
comment on column migtest_e_history.test_string is 'Column altered to long now';
create table migtest_e_history2 (
id integer generated by default as identity not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer generated by default as identity not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer generated by default as identity not null,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer generated by default as identity not null,
test_number integer,
test_boolean boolean default false not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer generated by default as identity not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer generated by default as identity not null,
test_string varchar(255),
deleted boolean default false not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
create table migtest_oto_child (
id integer generated by default as identity not null,
name varchar(255),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- apply alter tables
alter table migtest_e_history add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history2 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history3 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history4 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history5 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history6 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
-- apply post alter
create table migtest_e_history_history(like migtest_e_history);
create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history;
create or replace function migtest_e_history_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 migtest_e_history_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history_history_upd
before update or delete on migtest_e_history
for each row execute procedure migtest_e_history_history_version();
create table migtest_e_history2_history(like migtest_e_history2);
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 $$
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 migtest_e_history2_history (sys_period,id, test_string, test_string3, new_column) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history2_history (sys_period,id, test_string, test_string3, new_column) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history2_history_upd
before update or delete on migtest_e_history2
for each row execute procedure migtest_e_history2_history_version();
create table migtest_e_history3_history(like migtest_e_history3);
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
create or replace function migtest_e_history3_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 migtest_e_history3_history (sys_period,id) values (tstzrange(lowerTs,upperTs), OLD.id);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history3_history (sys_period,id) values (tstzrange(lowerTs,upperTs), OLD.id);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history3_history_upd
before update or delete on migtest_e_history3
for each row execute procedure migtest_e_history3_history_version();
create table migtest_e_history4_history(like migtest_e_history4);
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
create or replace function migtest_e_history4_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 migtest_e_history4_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history4_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history4_history_upd
before update or delete on migtest_e_history4
for each row execute procedure migtest_e_history4_history_version();
create table migtest_e_history5_history(like migtest_e_history5);
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
create or replace function migtest_e_history5_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 migtest_e_history5_history (sys_period,id, test_number, test_boolean) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number, OLD.test_boolean);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history5_history (sys_period,id, test_number, test_boolean) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number, OLD.test_boolean);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
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 table migtest_e_history6_history(like migtest_e_history6);
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
create or replace function migtest_e_history6_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 migtest_e_history6_history (sys_period,id, test_number1, test_number2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number1, OLD.test_number2);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history6_history (sys_period,id, test_number1, test_number2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number1, OLD.test_number2);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history6_history_upd
before update or delete on migtest_e_history6
for each row execute procedure migtest_e_history6_history_version();
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
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_migtest_oto_child_name on migtest_oto_child (name);
@@ -0,0 +1,206 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id),
foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key),
foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict
);
create table migtest_fk_cascade (
id integer not null,
one_id integer,
constraint pk_migtest_fk_cascade primary key (id),
foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict
);
create table migtest_fk_cascade_one (
id integer not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id integer not null,
one_id integer,
constraint pk_migtest_fk_none primary key (id),
foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict
);
create table migtest_fk_none_via_join (
id integer not null,
one_id integer,
constraint pk_migtest_fk_none_via_join primary key (id),
foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict
);
create table migtest_fk_one (
id integer not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id integer not null,
one_id integer,
constraint pk_migtest_fk_set_null primary key (id),
foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict
);
create table migtest_e_basic (
id integer not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date timestamp,
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field int default 1 not null,
new_boolean_field2 int default 1 not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id),
foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict
);
create table migtest_e_enum (
id integer not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer not null,
test_string integer,
constraint pk_migtest_e_history primary key (id)
);
create table migtest_e_history2 (
id integer not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer not null,
test_number integer,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer not null,
test_number integer,
test_boolean int default 0 not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer not null,
test_string varchar(255),
deleted int default 0 not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id integer not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id),
foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict,
foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict
);
create table migtest_mtm_m (
id integer not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id integer not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id),
foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict,
foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id integer not null,
value varchar(255) not null,
foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict
);
create table migtest_oto_child (
id integer not null,
name varchar(255),
master_id integer,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id),
foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict
);
create table migtest_oto_master (
id integer not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- foreign keys and indices
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,284 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer not null,
assoc_one nvarchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create sequence migtest_ckey_assoc_seq as bigint start with 1;
create table migtest_ckey_detail (
id integer not null,
something nvarchar(255),
one_key integer,
two_key nvarchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create sequence migtest_ckey_detail_seq as bigint start with 1;
create table migtest_ckey_parent (
one_key integer not null,
two_key nvarchar(127) not null,
name nvarchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id numeric(19) not null,
one_id numeric(19),
constraint pk_migtest_fk_cascade primary key (id)
);
create sequence migtest_fk_cascade_seq as bigint start with 1;
create table migtest_fk_cascade_one (
id numeric(19) not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create sequence migtest_fk_cascade_one_seq as bigint start with 1;
create table migtest_fk_none (
id numeric(19) not null,
one_id numeric(19),
constraint pk_migtest_fk_none primary key (id)
);
create sequence migtest_fk_none_seq as bigint start with 1;
create table migtest_fk_none_via_join (
id numeric(19) not null,
one_id numeric(19),
constraint pk_migtest_fk_none_via_join primary key (id)
);
create sequence migtest_fk_none_via_join_seq as bigint start with 1;
create table migtest_fk_one (
id numeric(19) not null,
constraint pk_migtest_fk_one primary key (id)
);
create sequence migtest_fk_one_seq as bigint start with 1;
create table migtest_fk_set_null (
id numeric(19) not null,
one_id numeric(19),
constraint pk_migtest_fk_set_null primary key (id)
);
create sequence migtest_fk_set_null_seq as bigint start with 1;
create table migtest_e_basic (
id integer not null,
status nvarchar(1) default 'A' not null,
status2 nvarchar(127),
name nvarchar(127),
description nvarchar(127),
some_date datetime2,
new_string_field nvarchar(255) default 'foo''bar' not null,
new_boolean_field bit default 1 not null,
new_boolean_field2 bit default 1 not null,
indextest1 nvarchar(127),
indextest2 nvarchar(127),
indextest3 nvarchar(127),
indextest4 nvarchar(127),
indextest5 nvarchar(127),
indextest6 nvarchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint pk_migtest_e_basic primary key (id)
);
create sequence migtest_e_basic_seq as bigint start with 1;
create table migtest_e_enum (
id integer not null,
test_status nvarchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create sequence migtest_e_enum_seq as bigint start with 1;
create table migtest_e_history (
id integer not null,
test_string numeric(19),
constraint pk_migtest_e_history primary key (id)
);
create sequence migtest_e_history_seq as bigint start with 1;
create table migtest_e_history2 (
id integer not null,
test_string nvarchar(255) default 'unknown' not null,
test_string2 nvarchar(255),
test_string3 nvarchar(255) default 'unknown' not null,
new_column nvarchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create sequence migtest_e_history2_seq as bigint start with 1;
create table migtest_e_history3 (
id integer not null,
test_string nvarchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create sequence migtest_e_history3_seq as bigint start with 1;
create table migtest_e_history4 (
id integer not null,
test_number numeric(19),
constraint pk_migtest_e_history4 primary key (id)
);
create sequence migtest_e_history4_seq as bigint start with 1;
create table migtest_e_history5 (
id integer not null,
test_number integer,
test_boolean bit default 0 not null,
constraint pk_migtest_e_history5 primary key (id)
);
create sequence migtest_e_history5_seq as bigint start with 1;
create table migtest_e_history6 (
id integer not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create sequence migtest_e_history6_seq as bigint start with 1;
create table migtest_e_softdelete (
id integer not null,
test_string nvarchar(255),
deleted bit default 0 not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create sequence migtest_e_softdelete_seq as bigint start with 1;
create table migtest_e_user (
id integer not null,
constraint pk_migtest_e_user primary key (id)
);
create sequence migtest_e_user_seq as bigint start with 1;
create table migtest_mtm_c (
id integer not null,
name nvarchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create sequence migtest_mtm_c_seq as bigint start with 1;
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id numeric(19) not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id numeric(19) not null,
name nvarchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create sequence migtest_mtm_m_seq as bigint start with 1;
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id numeric(19) not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id numeric(19) not null,
value nvarchar(255) not null
);
create table migtest_oto_child (
id integer not null,
name nvarchar(255),
master_id numeric(19),
constraint pk_migtest_oto_child primary key (id)
);
create sequence migtest_oto_child_seq as bigint start with 1;
create table migtest_oto_master (
id numeric(19) not null,
name nvarchar(255),
constraint pk_migtest_oto_master primary key (id)
);
create sequence migtest_oto_master_seq as bigint start with 1;
-- apply post alter
create unique nonclustered index uq_migtest_e_basic_description on migtest_e_basic(description) where description is not null;
create unique nonclustered index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) where indextest1 is not null;
create unique nonclustered index uq_migtest_e_basic_name on migtest_e_basic(name) where name is not null;
create unique nonclustered index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) where indextest4 is not null;
create unique nonclustered index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) where indextest5 is not null;
alter table migtest_e_history
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
period for system_time (sys_periodFrom, sys_periodTo);
alter table migtest_e_history set (system_versioning = on (history_table=dbo.migtest_e_history_history));
alter table migtest_e_history2
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
period for system_time (sys_periodFrom, sys_periodTo);
alter table migtest_e_history2 set (system_versioning = on (history_table=dbo.migtest_e_history2_history));
alter table migtest_e_history3
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
period for system_time (sys_periodFrom, sys_periodTo);
alter table migtest_e_history3 set (system_versioning = on (history_table=dbo.migtest_e_history3_history));
alter table migtest_e_history4
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
period for system_time (sys_periodFrom, sys_periodTo);
alter table migtest_e_history4 set (system_versioning = on (history_table=dbo.migtest_e_history4_history));
alter table migtest_e_history5
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
period for system_time (sys_periodFrom, sys_periodTo);
alter table migtest_e_history5 set (system_versioning = on (history_table=dbo.migtest_e_history5_history));
alter table migtest_e_history6
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
period for system_time (sys_periodFrom, sys_periodTo);
alter table migtest_e_history6 set (system_versioning = on (history_table=dbo.migtest_e_history6_history));
create unique nonclustered index uq_migtest_oto_child_master_id on migtest_oto_child(master_id) where master_id is not null;
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key);
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id);
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id);
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id);
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id);
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id);
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id);
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);
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id);
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id);
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -9,6 +9,8 @@ create table migtest_ckey_assoc (
create table migtest_ckey_detail (
id integer generated by default as identity not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
@@ -16,6 +18,7 @@ create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
@@ -56,33 +59,36 @@ create table migtest_fk_set_null (
create table migtest_e_basic (
id integer generated by default as identity not null,
status varchar(1),
status2 varchar(1) default 'N' not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
description_file bytea,
some_date timestamptz,
old_boolean boolean default false not null,
old_boolean2 boolean,
eref_id integer,
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field boolean default true not null,
new_boolean_field2 boolean default true not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
user_id integer default 23 not null,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I')),
constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')),
constraint uq_migtest_e_basic_indextest2 unique (indextest2),
constraint uq_migtest_e_basic_indextest6 unique (indextest6),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer generated by default as identity not null,
test_status varchar(1),
constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')),
constraint pk_migtest_e_enum primary key (id)
);
@@ -91,12 +97,15 @@ create table migtest_e_history (
test_string bigint,
constraint pk_migtest_e_history primary key (id)
);
comment on table migtest_e_history is 'We have history now';
comment on column migtest_e_history.test_string is 'Column altered to long now';
create table migtest_e_history2 (
id integer generated by default as identity not null,
test_string varchar(255),
obsolete_string1 varchar(255),
obsolete_string2 varchar(255),
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
@@ -108,51 +117,70 @@ create table migtest_e_history3 (
create table migtest_e_history4 (
id integer generated by default as identity not null,
test_number integer,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer generated by default as identity not null,
test_number integer,
test_boolean boolean default false not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer generated by default as identity not null,
test_number1 integer,
test_number2 integer default 7 not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_ref (
id integer generated by default as identity not null,
name varchar(127) not null,
constraint uq_migtest_e_ref_name unique (name),
constraint pk_migtest_e_ref primary key (id)
);
create table migtest_e_softdelete (
id integer generated by default as identity not null,
test_string varchar(255),
deleted boolean default false not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
create table migtest_oto_child (
id integer generated by default as identity not null,
name varchar(255),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
@@ -162,60 +190,52 @@ create table migtest_oto_master (
constraint pk_migtest_oto_master primary key (id)
);
create index if not exists ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
create index if not exists ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict;
create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
-- apply alter tables
alter table migtest_e_history add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history2 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history3 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history4 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history5 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history6 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
-- apply post alter
create table migtest_e_history_history(
id integer,
test_string bigint,
sys_period tstzrange
);
create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history;
create or replace function migtest_e_history_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 migtest_e_history_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history_history_upd
before update or delete on migtest_e_history
for each row execute procedure migtest_e_history_history_version();
create table migtest_e_history2_history(
id integer,
test_string varchar(255),
obsolete_string1 varchar(255),
obsolete_string2 varchar(255),
test_string2 varchar(255),
test_string3 varchar(255),
new_column varchar(20),
sys_period tstzrange
);
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
alter table migtest_e_history3 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
create table migtest_e_history3_history(
id integer,
test_string varchar(255),
sys_period tstzrange
);
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
alter table migtest_e_history4 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
create table migtest_e_history4_history(
id integer,
test_number integer,
sys_period tstzrange
);
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
alter table migtest_e_history5 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
create table migtest_e_history5_history(
id integer,
test_number integer,
sys_period tstzrange
);
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
alter table migtest_e_history6 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
create table migtest_e_history6_history(
id integer,
test_number1 integer,
test_number2 integer,
sys_period tstzrange
);
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
create or replace function migtest_e_history2_history_version() returns trigger as $$
declare
lowerTs timestamptz;
@@ -224,11 +244,11 @@ begin
lowerTs = lower(OLD.sys_period);
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
if (TG_OP = 'UPDATE') then
insert into migtest_e_history2_history (sys_period,id, test_string, obsolete_string2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.obsolete_string2);
insert into migtest_e_history2_history (sys_period,id, test_string, test_string3, new_column) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history2_history (sys_period,id, test_string, obsolete_string2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.obsolete_string2);
insert into migtest_e_history2_history (sys_period,id, test_string, test_string3, new_column) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
return old;
end if;
end;
@@ -238,6 +258,13 @@ create trigger migtest_e_history2_history_upd
before update or delete on migtest_e_history2
for each row execute procedure migtest_e_history2_history_version();
create table migtest_e_history3_history(
id integer,
test_string varchar(255),
sys_period tstzrange
);
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
create or replace function migtest_e_history3_history_version() returns trigger as $$
declare
lowerTs timestamptz;
@@ -246,11 +273,11 @@ begin
lowerTs = lower(OLD.sys_period);
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
if (TG_OP = 'UPDATE') then
insert into migtest_e_history3_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
insert into migtest_e_history3_history (sys_period,id) values (tstzrange(lowerTs,upperTs), OLD.id);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history3_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
insert into migtest_e_history3_history (sys_period,id) values (tstzrange(lowerTs,upperTs), OLD.id);
return old;
end if;
end;
@@ -260,6 +287,13 @@ create trigger migtest_e_history3_history_upd
before update or delete on migtest_e_history3
for each row execute procedure migtest_e_history3_history_version();
create table migtest_e_history4_history(
id integer,
test_number bigint,
sys_period tstzrange
);
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
create or replace function migtest_e_history4_history_version() returns trigger as $$
declare
lowerTs timestamptz;
@@ -282,6 +316,14 @@ create trigger migtest_e_history4_history_upd
before update or delete on migtest_e_history4
for each row execute procedure migtest_e_history4_history_version();
create table migtest_e_history5_history(
id integer,
test_number integer,
test_boolean boolean,
sys_period tstzrange
);
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
create or replace function migtest_e_history5_history_version() returns trigger as $$
declare
lowerTs timestamptz;
@@ -290,11 +332,11 @@ begin
lowerTs = lower(OLD.sys_period);
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
if (TG_OP = 'UPDATE') then
insert into migtest_e_history5_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
insert into migtest_e_history5_history (sys_period,id, test_number, test_boolean) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number, OLD.test_boolean);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history5_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
insert into migtest_e_history5_history (sys_period,id, test_number, test_boolean) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number, OLD.test_boolean);
return old;
end if;
end;
@@ -304,6 +346,14 @@ 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 table migtest_e_history6_history(
id integer,
test_number1 integer,
test_number2 integer,
sys_period tstzrange
);
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
create or replace function migtest_e_history6_history_version() returns trigger as $$
declare
lowerTs timestamptz;
@@ -326,3 +376,45 @@ create trigger migtest_e_history6_history_upd
before update or delete on migtest_e_history6
for each row execute procedure migtest_e_history6_history_version();
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
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);
@@ -0,0 +1,312 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer generated by default as identity not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer generated by default as identity not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer generated by default as identity not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date timestamp,
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field boolean default true not null,
new_boolean_field2 boolean default true not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer generated by default as identity not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer generated by default as identity not null,
test_string bigint,
constraint pk_migtest_e_history primary key (id)
);
comment on table migtest_e_history is 'We have history now';
comment on column migtest_e_history.test_string is 'Column altered to long now';
create table migtest_e_history2 (
id integer generated by default as identity not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer generated by default as identity not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer generated by default as identity not null,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer generated by default as identity not null,
test_number integer,
test_boolean boolean default false not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer generated by default as identity not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer generated by default as identity not null,
test_string varchar(255),
deleted boolean default false not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
) in TESTTS index in TESTTS long in TESTTS;
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
) in TESTTS index in TESTTS long in TESTTS;
create table migtest_mtm_m (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
) in TSMASTER index in TSMASTER long in TSMASTER;
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
) in TSMASTER index in TSMASTER long in TSMASTER;
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
) in TSMASTER index in TSMASTER long in TSMASTER;
create table migtest_oto_child (
id integer generated by default as identity not null,
name varchar(255),
master_id bigint,
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- apply alter tables
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_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_description on migtest_e_basic(description) exclude null keys;
create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) exclude null keys;
create unique index uq_migtest_e_basic_name on migtest_e_basic(name) exclude null keys;
create unique index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) exclude null keys;
create unique index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) exclude null keys;
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;
create table migtest_e_history2_history (
id integer not null,
test_string varchar(255) not null,
test_string2 varchar(255),
test_string3 varchar(255) not null,
new_column varchar(20),
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 bigint,
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,
test_boolean boolean 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_history5 add versioning use history table migtest_e_history5_history;
create table migtest_e_history6_history (
id integer not null,
test_number1 integer not null,
test_number2 integer,
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;
create unique index uq_migtest_oto_child_master_id on migtest_oto_child(master_id) exclude null keys;
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,7 @@
create or replace view order_agg_vw as
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
sum(d.ship_qty * d.unit_price) as ship_total
from o_order_detail d
group by d.order_id
@@ -0,0 +1,5 @@
-1602289007, I__create_tablespaces.sql
-1178292807, 1.0__initial.sql
-133543359, R__db2_explain_tables.sql
561281075, R__order_views.sql
@@ -0,0 +1,306 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer generated by default as identity not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer generated by default as identity not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer generated by default as identity not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date timestamp,
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field boolean default true not null,
new_boolean_field2 boolean default true not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer generated by default as identity not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer generated by default as identity not null,
test_string bigint,
constraint pk_migtest_e_history primary key (id)
);
comment on table migtest_e_history is 'We have history now';
comment on column migtest_e_history.test_string is 'Column altered to long now';
create table migtest_e_history2 (
id integer generated by default as identity not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer generated by default as identity not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer generated by default as identity not null,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer generated by default as identity not null,
test_number integer,
test_boolean boolean default false not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer generated by default as identity not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer generated by default as identity not null,
test_string varchar(255),
deleted boolean default false not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
create table migtest_oto_child (
id integer generated by default as identity not null,
name varchar(255),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- apply alter tables
alter table migtest_e_history add column sys_period_start timestamp default now();
alter table migtest_e_history add column sys_period_end timestamp;
alter table migtest_e_history2 add column sys_period_start timestamp default now();
alter table migtest_e_history2 add column sys_period_end timestamp;
alter table migtest_e_history3 add column sys_period_start timestamp default now();
alter table migtest_e_history3 add column sys_period_end timestamp;
alter table migtest_e_history4 add column sys_period_start timestamp default now();
alter table migtest_e_history4 add column sys_period_end timestamp;
alter table migtest_e_history5 add column sys_period_start timestamp default now();
alter table migtest_e_history5 add column sys_period_end timestamp;
alter table migtest_e_history6 add column sys_period_start timestamp default now();
alter table migtest_e_history6 add column sys_period_end timestamp;
-- apply post alter
create table migtest_e_history_history(
id integer,
test_string bigint,
sys_period_start timestamp,
sys_period_end timestamp
);
create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history;
create trigger migtest_e_history_history_upd before update,delete on migtest_e_history for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create table migtest_e_history2_history(
id integer,
test_string varchar(255),
test_string2 varchar(255),
test_string3 varchar(255),
new_column varchar(20),
sys_period_start timestamp,
sys_period_end timestamp
);
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.config.dbplatform.h2.H2HistoryTrigger";
create table migtest_e_history3_history(
id integer,
test_string varchar(255),
sys_period_start timestamp,
sys_period_end timestamp
);
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create table migtest_e_history4_history(
id integer,
test_number bigint,
sys_period_start timestamp,
sys_period_end timestamp
);
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create table migtest_e_history5_history(
id integer,
test_number integer,
test_boolean boolean,
sys_period_start timestamp,
sys_period_end timestamp
);
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.config.dbplatform.h2.H2HistoryTrigger";
create table migtest_e_history6_history(
id integer,
test_number1 integer,
test_number2 integer,
sys_period_start timestamp,
sys_period_end timestamp
);
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
create trigger migtest_e_history6_history_upd before update,delete on migtest_e_history6 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,3 @@
-- h2 and postgres script
@@ -0,0 +1,7 @@
create or replace view order_agg_vw as
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
sum(d.ship_qty * d.unit_price) as ship_total
from o_order_detail d
group by d.order_id
@@ -0,0 +1,4 @@
-489443802, 1.0__initial.sql
783227075, R__multi_comments.sql
561281075, R__order_views.sql
@@ -0,0 +1,312 @@
-- Migrationscripts for ebean unittest
-- apply changes
create column table migtest_ckey_assoc (
id integer generated by default as identity not null,
assoc_one nvarchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create column table migtest_ckey_detail (
id integer generated by default as identity not null,
something nvarchar(255),
one_key integer,
two_key nvarchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create column table migtest_ckey_parent (
one_key integer not null,
two_key nvarchar(127) not null,
name nvarchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create column table migtest_fk_cascade (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create column table migtest_fk_cascade_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create column table migtest_fk_none (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create column table migtest_fk_none_via_join (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create column table migtest_fk_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_one primary key (id)
);
create column table migtest_fk_set_null (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create column table migtest_e_basic (
id integer generated by default as identity not null,
status nvarchar(1) default 'A' not null,
status2 nvarchar(127),
name nvarchar(127),
description nvarchar(127),
some_date timestamp,
new_string_field nvarchar(255) default 'foo''bar' not null,
new_boolean_field boolean default true not null,
new_boolean_field2 boolean default true not null,
indextest1 nvarchar(127),
indextest2 nvarchar(127),
indextest3 nvarchar(127),
indextest4 nvarchar(127),
indextest5 nvarchar(127),
indextest6 nvarchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create column table migtest_e_enum (
id integer generated by default as identity not null,
test_status nvarchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create column table migtest_e_history (
id integer generated by default as identity not null,
test_string bigint,
constraint pk_migtest_e_history primary key (id)
);
comment on table migtest_e_history is 'We have history now';
comment on column migtest_e_history.test_string is 'Column altered to long now';
create column table migtest_e_history2 (
id integer generated by default as identity not null,
test_string nvarchar(255) default 'unknown' not null,
test_string2 nvarchar(255),
test_string3 nvarchar(255) default 'unknown' not null,
new_column nvarchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create column table migtest_e_history3 (
id integer generated by default as identity not null,
test_string nvarchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create column table migtest_e_history4 (
id integer generated by default as identity not null,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create column table migtest_e_history5 (
id integer generated by default as identity not null,
test_number integer,
test_boolean boolean default false not null,
constraint pk_migtest_e_history5 primary key (id)
);
create column table migtest_e_history6 (
id integer generated by default as identity not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create column table migtest_e_softdelete (
id integer generated by default as identity not null,
test_string nvarchar(255),
deleted boolean default false not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create column table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create column table migtest_mtm_c (
id integer generated by default as identity not null,
name nvarchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create column table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create column table migtest_mtm_m (
id bigint generated by default as identity not null,
name nvarchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create column table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create column table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value nvarchar(255) not null
);
create column table migtest_oto_child (
id integer generated by default as identity not null,
name nvarchar(255),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create column table migtest_oto_master (
id bigint generated by default as identity not null,
name nvarchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- apply alter tables
-- apply post alter
create column table migtest_e_history_history (
id integer,
test_string bigint,
sys_period_start timestamp,
sys_period_end timestamp
);
alter table migtest_e_history add (
sys_period_start TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW START,
sys_period_end TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW END
);
alter table migtest_e_history add period for system_time(sys_period_start,sys_period_end);
alter table migtest_e_history add system versioning history table migtest_e_history_history;
create column table migtest_e_history2_history (
id integer,
test_string nvarchar(255) default 'unknown' not null,
test_string2 nvarchar(255),
test_string3 nvarchar(255) default 'unknown' not null,
new_column nvarchar(20),
sys_period_start timestamp,
sys_period_end timestamp
);
alter table migtest_e_history2 add (
sys_period_start TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW START,
sys_period_end TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW END
);
alter table migtest_e_history2 add period for system_time(sys_period_start,sys_period_end);
alter table migtest_e_history2 add system versioning history table migtest_e_history2_history;
create column table migtest_e_history3_history (
id integer,
test_string nvarchar(255),
sys_period_start timestamp,
sys_period_end timestamp
);
alter table migtest_e_history3 add (
sys_period_start TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW START,
sys_period_end TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW END
);
alter table migtest_e_history3 add period for system_time(sys_period_start,sys_period_end);
alter table migtest_e_history3 add system versioning history table migtest_e_history3_history;
create column table migtest_e_history4_history (
id integer,
test_number bigint,
sys_period_start timestamp,
sys_period_end timestamp
);
alter table migtest_e_history4 add (
sys_period_start TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW START,
sys_period_end TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW END
);
alter table migtest_e_history4 add period for system_time(sys_period_start,sys_period_end);
alter table migtest_e_history4 add system versioning history table migtest_e_history4_history;
create column table migtest_e_history5_history (
id integer,
test_number integer,
test_boolean boolean default false not null,
sys_period_start timestamp,
sys_period_end timestamp
);
alter table migtest_e_history5 add (
sys_period_start TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW START,
sys_period_end TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW END
);
alter table migtest_e_history5 add period for system_time(sys_period_start,sys_period_end);
alter table migtest_e_history5 add system versioning history table migtest_e_history5_history;
create column table migtest_e_history6_history (
id integer,
test_number1 integer default 42 not null,
test_number2 integer,
sys_period_start timestamp,
sys_period_end timestamp
);
alter table migtest_e_history6 add (
sys_period_start TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW START,
sys_period_end TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW END
);
alter table migtest_e_history6 add period for system_time(sys_period_start,sys_period_end);
alter table migtest_e_history6 add system versioning history table migtest_e_history6_history;
-- foreign keys and indices
create inverted hash index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
-- explicit index "ix_migtest_ckey_parent_assoc_id" for single column "assoc_id" of table "migtest_ckey_parent" is not necessary;
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_fk_cascade_one_id" for single column "one_id" of table "migtest_fk_cascade" is not necessary;
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_fk_none_one_id" for single column "one_id" of table "migtest_fk_none" is not necessary;
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_fk_none_via_join_one_id" for single column "one_id" of table "migtest_fk_none_via_join" is not necessary;
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_fk_set_null_one_id" for single column "one_id" of table "migtest_fk_set_null" is not necessary;
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_e_basic_user_id" for single column "user_id" of table "migtest_e_basic" is not necessary;
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c" for single column "migtest_mtm_c_id" of table "migtest_mtm_c_migtest_mtm_m" is not necessary;
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;
-- explicit index "ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m" for single column "migtest_mtm_m_id" of table "migtest_mtm_c_migtest_mtm_m" is not necessary;
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m" for single column "migtest_mtm_m_id" of table "migtest_mtm_m_migtest_mtm_c" is not necessary;
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c" for single column "migtest_mtm_c_id" of table "migtest_mtm_m_migtest_mtm_c" is not necessary;
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id" for single column "migtest_mtm_m_id" of table "migtest_mtm_m_phone_numbers" is not necessary;
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
-- 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;
@@ -0,0 +1,33 @@
-- Inital script to create stored procedures etc for the hana platform
delimiter $$
--
-- PROCEDURE: usp_ebean_drop_foreign_keys TABLE, COLUMN
-- deletes all constraints and foreign keys referring to TABLE.COLUMN
--
CREATE OR REPLACE PROCEDURE usp_ebean_drop_foreign_keys(IN table_name NVARCHAR(256), IN column_name NVARCHAR(256))
AS
BEGIN
DECLARE foreign_key_names TABLE(CONSTRAINT_NAME NVARCHAR(256), TABLE_NAME NVARCHAR(256));
DECLARE i INT;
foreign_key_names = SELECT CONSTRAINT_NAME, TABLE_NAME FROM SYS.REFERENTIAL_CONSTRAINTS WHERE SCHEMA_NAME=CURRENT_SCHEMA AND TABLE_NAME=UPPER(:table_name) AND COLUMN_NAME=UPPER(:column_name);
FOR I IN 1 .. RECORD_COUNT(:foreign_key_names) DO
EXEC 'ALTER TABLE "' || ESCAPE_DOUBLE_QUOTES(:foreign_key_names.TABLE_NAME[i]) || '" DROP CONSTRAINT "' || ESCAPE_DOUBLE_QUOTES(:foreign_key_names.CONSTRAINT_NAME[i]) || '"';
END FOR;
END;
$$
delimiter $$
--
-- PROCEDURE: usp_ebean_drop_column TABLE, COLUMN
-- deletes the column and ensures that all indices and constraints are dropped first
--
CREATE OR REPLACE PROCEDURE usp_ebean_drop_column(IN table_name NVARCHAR(256), IN column_name NVARCHAR(256))
AS
BEGIN
CALL usp_ebean_drop_foreign_keys(table_name, column_name);
EXEC 'ALTER TABLE "' || UPPER(ESCAPE_DOUBLE_QUOTES(table_name)) || '" DROP ("' || UPPER(ESCAPE_DOUBLE_QUOTES(column_name)) || '")';
END;
$$
@@ -0,0 +1,7 @@
create view order_agg_vw as
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
sum(d.ship_qty * d.unit_price) as ship_total
from o_order_detail d
group by d.order_id;
@@ -0,0 +1,4 @@
-745347271, I__create_procs.sql
1457017245, 1.0__initial.sql
1906063401, R__order_views_hana.sql
@@ -0,0 +1,233 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer generated by default as identity (start with 1) not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer generated by default as identity (start with 1) not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint generated by default as identity (start with 1) not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint generated by default as identity (start with 1) not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint generated by default as identity (start with 1) not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint generated by default as identity (start with 1) not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint generated by default as identity (start with 1) not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint generated by default as identity (start with 1) not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer generated by default as identity (start with 1) not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date timestamp,
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field boolean default true not null,
new_boolean_field2 boolean default true not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer generated by default as identity (start with 1) not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer generated by default as identity (start with 1) not null,
test_string bigint,
constraint pk_migtest_e_history primary key (id)
);
comment on table migtest_e_history is 'We have history now';
comment on column migtest_e_history.test_string is 'Column altered to long now';
create table migtest_e_history2 (
id integer generated by default as identity (start with 1) not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer generated by default as identity (start with 1) not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer generated by default as identity (start with 1) not null,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer generated by default as identity (start with 1) not null,
test_number integer,
test_boolean boolean default false not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer generated by default as identity (start with 1) not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer generated by default as identity (start with 1) not null,
test_string varchar(255),
deleted boolean default false not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer generated by default as identity (start with 1) not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer generated by default as identity (start with 1) not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id bigint generated by default as identity (start with 1) not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
create table migtest_oto_child (
id integer generated by default as identity (start with 1) not null,
name varchar(255),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint generated by default as identity (start with 1) not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,8 @@
drop view order_agg_vw if exists ;
create view order_agg_vw as
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
sum(d.ship_qty * d.unit_price) as ship_total
from o_order_detail d
group by d.order_id;
@@ -0,0 +1,3 @@
-1869771532, 1.0__initial.sql
861001272, R__order_views_hsqldb.sql
@@ -0,0 +1,236 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer auto_increment not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer auto_increment not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint auto_increment not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint auto_increment not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer auto_increment not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date datetime(6),
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field tinyint(1) default 1 not null,
new_boolean_field2 tinyint(1) default 1 not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer auto_increment not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer auto_increment not null,
test_string bigint comment 'Column altered to long now',
constraint pk_migtest_e_history primary key (id)
) comment='We have history now';
create table migtest_e_history2 (
id integer auto_increment not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer auto_increment not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer auto_increment not null,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer auto_increment not null,
test_number integer,
test_boolean tinyint(1) default 0 not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer auto_increment not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer auto_increment not null,
test_string varchar(255),
deleted tinyint(1) default 0 not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer auto_increment not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer auto_increment not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id bigint auto_increment not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
create table migtest_oto_child (
id integer auto_increment not null,
name varchar(255),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint auto_increment not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- apply alter tables
alter table migtest_e_history add system versioning;
alter table migtest_e_history2 add system versioning;
alter table migtest_e_history3 add system versioning;
alter table migtest_e_history4 add system versioning;
alter table migtest_e_history5 add system versioning;
alter table migtest_e_history6 add system versioning;
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,48 @@
-- Inital script to create stored procedures etc for mysql platform
DROP PROCEDURE IF EXISTS usp_ebean_drop_foreign_keys;
delimiter $$
--
-- PROCEDURE: usp_ebean_drop_foreign_keys TABLE, COLUMN
-- deletes all constraints and foreign keys referring to TABLE.COLUMN
--
CREATE PROCEDURE usp_ebean_drop_foreign_keys(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE c_fk_name CHAR(255);
DECLARE curs CURSOR FOR SELECT CONSTRAINT_NAME from information_schema.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = DATABASE() and TABLE_NAME = p_table_name and COLUMN_NAME = p_column_name
AND REFERENCED_TABLE_NAME IS NOT NULL;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN curs;
read_loop: LOOP
FETCH curs INTO c_fk_name;
IF done THEN
LEAVE read_loop;
END IF;
SET @sql = CONCAT('ALTER TABLE ', p_table_name, ' DROP FOREIGN KEY ', c_fk_name);
PREPARE stmt FROM @sql;
EXECUTE stmt;
END LOOP;
CLOSE curs;
END
$$
DROP PROCEDURE IF EXISTS usp_ebean_drop_column;
delimiter $$
--
-- PROCEDURE: usp_ebean_drop_column TABLE, COLUMN
-- deletes the column and ensures that all indices and constraints are dropped first
--
CREATE PROCEDURE usp_ebean_drop_column(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
BEGIN
CALL usp_ebean_drop_foreign_keys(p_table_name, p_column_name);
SET @sql = CONCAT('ALTER TABLE ', p_table_name, ' DROP COLUMN ', p_column_name);
PREPARE stmt FROM @sql;
EXECUTE stmt;
END
$$
@@ -0,0 +1,7 @@
create or replace view order_agg_vw as
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
sum(d.ship_qty * d.unit_price) as ship_total
from o_order_detail d
group by d.order_id
@@ -0,0 +1,4 @@
1835064798, I__create_procs.sql
399669760, 1.0__initial.sql
561281075, R__order_views.sql
@@ -0,0 +1,150 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<migration xmlns="http://ebean-orm.github.io/xml/ns/dbmigration">
<changeSet type="apply">
<createTable name="migtest_ckey_assoc" pkName="pk_migtest_ckey_assoc">
<column name="id" type="integer" primaryKey="true"/>
<column name="assoc_one" type="varchar"/>
</createTable>
<createTable name="migtest_ckey_detail" pkName="pk_migtest_ckey_detail">
<column name="id" type="integer" primaryKey="true"/>
<column name="something" type="varchar"/>
<column name="one_key" type="integer"/>
<column name="two_key" type="varchar(127)"/>
<foreignKey name="fk_migtest_ckey_detail_parent" columnNames="one_key,two_key" refColumnNames="one_key,two_key" refTableName="migtest_ckey_parent" indexName="ix_migtest_ckey_detail_parent"/>
</createTable>
<createTable name="migtest_ckey_parent" pkName="pk_migtest_ckey_parent">
<column name="one_key" type="integer" primaryKey="true"/>
<column name="two_key" type="varchar(127)" primaryKey="true"/>
<column name="name" type="varchar"/>
<column name="assoc_id" type="integer" references="migtest_ckey_assoc.id" foreignKeyName="fk_migtest_ckey_parent_assoc_id" foreignKeyIndex="ix_migtest_ckey_parent_assoc_id"/>
<column name="version" type="integer" notnull="true"/>
</createTable>
<createTable name="migtest_fk_cascade" pkName="pk_migtest_fk_cascade">
<column name="id" type="bigint" primaryKey="true"/>
<column name="one_id" type="bigint" references="migtest_fk_cascade_one.id" foreignKeyName="fk_migtest_fk_cascade_one_id" foreignKeyIndex="ix_migtest_fk_cascade_one_id" foreignKeyOnDelete="RESTRICT" foreignKeyOnUpdate="RESTRICT"/>
</createTable>
<createTable name="migtest_fk_cascade_one" pkName="pk_migtest_fk_cascade_one">
<column name="id" type="bigint" primaryKey="true"/>
</createTable>
<createTable name="migtest_fk_none" pkName="pk_migtest_fk_none">
<column name="id" type="bigint" primaryKey="true"/>
<column name="one_id" type="bigint" references="migtest_fk_one.id" foreignKeyName="fk_migtest_fk_none_one_id" foreignKeyIndex="ix_migtest_fk_none_one_id" foreignKeyOnDelete="RESTRICT" foreignKeyOnUpdate="RESTRICT"/>
</createTable>
<createTable name="migtest_fk_none_via_join" pkName="pk_migtest_fk_none_via_join">
<column name="id" type="bigint" primaryKey="true"/>
<column name="one_id" type="bigint" references="migtest_fk_one.id" foreignKeyName="fk_migtest_fk_none_via_join_one_id" foreignKeyIndex="ix_migtest_fk_none_via_join_one_id"/>
</createTable>
<createTable name="migtest_fk_one" pkName="pk_migtest_fk_one">
<column name="id" type="bigint" primaryKey="true"/>
</createTable>
<createTable name="migtest_fk_set_null" pkName="pk_migtest_fk_set_null">
<column name="id" type="bigint" primaryKey="true"/>
<column name="one_id" type="bigint" references="migtest_fk_one.id" foreignKeyName="fk_migtest_fk_set_null_one_id" foreignKeyIndex="ix_migtest_fk_set_null_one_id" foreignKeyOnDelete="RESTRICT" foreignKeyOnUpdate="RESTRICT"/>
</createTable>
<createTable name="migtest_e_basic" pkName="pk_migtest_e_basic">
<column name="id" type="integer" primaryKey="true"/>
<column name="status" type="varchar(1)" defaultValue="'A'" notnull="true" checkConstraint="check ( status in ('N','A','I','?'))" checkConstraintName="ck_migtest_e_basic_status"/>
<column name="status2" type="varchar(127)"/>
<column name="name" type="varchar(127)"/>
<column name="description" type="varchar(127)" unique="uq_migtest_e_basic_description"/>
<column name="some_date" type="timestamp"/>
<column name="new_string_field" type="varchar" defaultValue="'foo''bar'" notnull="true"/>
<column name="new_boolean_field" type="boolean" defaultValue="true" notnull="true">
<after>
<ddl>update ${table} set ${column} = old_boolean</ddl>
</after>
</column>
<column name="new_boolean_field2" type="boolean" defaultValue="true" notnull="true"/>
<column name="indextest1" type="varchar(127)"/>
<column name="indextest2" type="varchar(127)"/>
<column name="indextest3" type="varchar(127)"/>
<column name="indextest4" type="varchar(127)"/>
<column name="indextest5" type="varchar(127)"/>
<column name="indextest6" type="varchar(127)"/>
<column name="progress" type="integer" defaultValue="0" notnull="true" checkConstraint="check ( progress in (0,1,2))" checkConstraintName="ck_migtest_e_basic_progress"/>
<column name="new_integer" type="integer" defaultValue="42" notnull="true"/>
<column name="user_id" type="integer" references="migtest_e_user.id" foreignKeyName="fk_migtest_e_basic_user_id" foreignKeyIndex="ix_migtest_e_basic_user_id"/>
<uniqueConstraint name="uq_migtest_e_basic_status_indextest1" columnNames="status,indextest1" oneToOne="false" nullableColumns="indextest1"/>
<uniqueConstraint name="uq_migtest_e_basic_name" columnNames="name" oneToOne="false" nullableColumns="name"/>
<uniqueConstraint name="uq_migtest_e_basic_indextest4" columnNames="indextest4" oneToOne="false" nullableColumns="indextest4"/>
<uniqueConstraint name="uq_migtest_e_basic_indextest5" columnNames="indextest5" oneToOne="false" nullableColumns="indextest5"/>
</createTable>
<createTable name="migtest_e_enum" pkName="pk_migtest_e_enum">
<column name="id" type="integer" primaryKey="true"/>
<column name="test_status" type="varchar(1)"/>
</createTable>
<createTable name="migtest_e_history" withHistory="true" pkName="pk_migtest_e_history" comment="We have history now">
<column name="id" type="integer" primaryKey="true"/>
<column name="test_string" type="bigint" comment="Column altered to long now"/>
</createTable>
<createTable name="migtest_e_history2" withHistory="true" pkName="pk_migtest_e_history2">
<column name="id" type="integer" primaryKey="true"/>
<column name="test_string" type="varchar" defaultValue="'unknown'" notnull="true"/>
<column name="test_string2" type="varchar" historyExclude="true"/>
<column name="test_string3" type="varchar" defaultValue="'unknown'" notnull="true"/>
<column name="new_column" type="varchar(20)"/>
</createTable>
<createTable name="migtest_e_history3" withHistory="true" pkName="pk_migtest_e_history3">
<column name="id" type="integer" primaryKey="true"/>
<column name="test_string" type="varchar" historyExclude="true"/>
</createTable>
<createTable name="migtest_e_history4" withHistory="true" pkName="pk_migtest_e_history4">
<column name="id" type="integer" primaryKey="true"/>
<column name="test_number" type="bigint"/>
</createTable>
<createTable name="migtest_e_history5" withHistory="true" pkName="pk_migtest_e_history5">
<column name="id" type="integer" primaryKey="true"/>
<column name="test_number" type="integer"/>
<column name="test_boolean" type="boolean" defaultValue="false" notnull="true"/>
</createTable>
<createTable name="migtest_e_history6" withHistory="true" pkName="pk_migtest_e_history6">
<column name="id" type="integer" primaryKey="true"/>
<column name="test_number1" type="integer" defaultValue="42" notnull="true"/>
<column name="test_number2" type="integer"/>
</createTable>
<createTable name="migtest_e_softdelete" pkName="pk_migtest_e_softdelete">
<column name="id" type="integer" primaryKey="true"/>
<column name="test_string" type="varchar"/>
<column name="deleted" type="boolean" defaultValue="false" notnull="true"/>
</createTable>
<createTable name="migtest_e_user" pkName="pk_migtest_e_user">
<column name="id" type="integer" primaryKey="true"/>
</createTable>
<createTable name="migtest_mtm_c" pkName="pk_migtest_mtm_c" tablespace="TESTTS" indexTablespace="TESTTS" lobTablespace="TESTTS">
<column name="id" type="integer" primaryKey="true"/>
<column name="name" type="varchar"/>
</createTable>
<createTable name="migtest_mtm_c_migtest_mtm_m" pkName="pk_migtest_mtm_c_migtest_mtm_m" tablespace="TESTTS" indexTablespace="TESTTS" lobTablespace="TESTTS">
<column name="migtest_mtm_c_id" type="integer" notnull="true" primaryKey="true"/>
<column name="migtest_mtm_m_id" type="bigint" notnull="true" primaryKey="true"/>
<foreignKey name="fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c" columnNames="migtest_mtm_c_id" refColumnNames="id" refTableName="migtest_mtm_c" indexName="ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c"/>
<foreignKey name="fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m" columnNames="migtest_mtm_m_id" refColumnNames="id" refTableName="migtest_mtm_m" indexName="ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m"/>
</createTable>
<createTable name="migtest_mtm_m" pkName="pk_migtest_mtm_m" tablespace="TSMASTER" indexTablespace="TSMASTER" lobTablespace="TSMASTER">
<column name="id" type="bigint" primaryKey="true"/>
<column name="name" type="varchar"/>
</createTable>
<createTable name="migtest_mtm_m_migtest_mtm_c" pkName="pk_migtest_mtm_m_migtest_mtm_c" tablespace="TSMASTER" indexTablespace="TSMASTER" lobTablespace="TSMASTER">
<column name="migtest_mtm_m_id" type="bigint" notnull="true" primaryKey="true"/>
<column name="migtest_mtm_c_id" type="integer" notnull="true" primaryKey="true"/>
<foreignKey name="fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m" columnNames="migtest_mtm_m_id" refColumnNames="id" refTableName="migtest_mtm_m" indexName="ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m"/>
<foreignKey name="fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c" columnNames="migtest_mtm_c_id" refColumnNames="id" refTableName="migtest_mtm_c" indexName="ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c"/>
</createTable>
<createTable name="migtest_mtm_m_phone_numbers" pkName="pk_migtest_mtm_m_phone_numbers" tablespace="TSMASTER" indexTablespace="TSMASTER" lobTablespace="TSMASTER">
<column name="migtest_mtm_m_id" type="bigint" notnull="true" references="migtest_mtm_m.id" foreignKeyName="fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id" foreignKeyIndex="ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id"/>
<column name="value" type="varchar" notnull="true"/>
</createTable>
<createTable name="migtest_oto_child" pkName="pk_migtest_oto_child">
<column name="id" type="integer" primaryKey="true"/>
<column name="name" type="varchar"/>
<column name="master_id" type="bigint" uniqueOneToOne="uq_migtest_oto_child_master_id" references="migtest_oto_master.id" foreignKeyName="fk_migtest_oto_child_master_id"/>
</createTable>
<createTable name="migtest_oto_master" pkName="pk_migtest_oto_master">
<column name="id" type="bigint" primaryKey="true"/>
<column name="name" type="varchar"/>
</createTable>
<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_migtest_oto_child_name" tableName="migtest_oto_child" columns="name" platforms="POSTGRES"/>
</changeSet>
</migration>
@@ -0,0 +1,362 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer auto_increment not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer auto_increment not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint auto_increment not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint auto_increment not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer auto_increment not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date datetime(6),
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field tinyint(1) default 1 not null,
new_boolean_field2 tinyint(1) default 1 not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer auto_increment not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer auto_increment not null,
test_string bigint comment 'Column altered to long now',
constraint pk_migtest_e_history primary key (id)
) comment='We have history now';
create table migtest_e_history2 (
id integer auto_increment not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer auto_increment not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer auto_increment not null,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer auto_increment not null,
test_number integer,
test_boolean tinyint(1) default 0 not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer auto_increment not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer auto_increment not null,
test_string varchar(255),
deleted tinyint(1) default 0 not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer auto_increment not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer auto_increment not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id bigint auto_increment not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
create table migtest_oto_child (
id integer auto_increment not null,
name varchar(255),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint auto_increment not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- apply alter tables
alter table migtest_e_history add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history add column sys_period_end datetime(6);
alter table migtest_e_history2 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history2 add column sys_period_end datetime(6);
alter table migtest_e_history3 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history3 add column sys_period_end datetime(6);
alter table migtest_e_history4 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history4 add column sys_period_end datetime(6);
alter table migtest_e_history5 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history5 add column sys_period_end datetime(6);
alter table migtest_e_history6 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history6 add column sys_period_end datetime(6);
-- apply post alter
create table migtest_e_history_history(
id integer,
test_string bigint,
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history;
lock tables migtest_e_history write;
delimiter $$
create trigger migtest_e_history_history_upd before update on migtest_e_history for each row begin
insert into migtest_e_history_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history_history_del before delete on migtest_e_history for each row begin
insert into migtest_e_history_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
end$$
unlock tables;
create table migtest_e_history2_history(
id integer,
test_string varchar(255),
test_string2 varchar(255),
test_string3 varchar(255),
new_column varchar(20),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
lock tables migtest_e_history2 write;
delimiter $$
create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, new_column) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, new_column) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
end$$
unlock tables;
create table migtest_e_history3_history(
id integer,
test_string varchar(255),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
lock tables migtest_e_history3 write;
delimiter $$
create trigger migtest_e_history3_history_upd before update on migtest_e_history3 for each row begin
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id) values (OLD.sys_period_start, now(6),OLD.id);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history3_history_del before delete on migtest_e_history3 for each row begin
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id) values (OLD.sys_period_start, now(6),OLD.id);
end$$
unlock tables;
create table migtest_e_history4_history(
id integer,
test_number bigint,
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
lock tables migtest_e_history4 write;
delimiter $$
create trigger migtest_e_history4_history_upd before update on migtest_e_history4 for each row begin
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history4_history_del before delete on migtest_e_history4 for each row begin
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
end$$
unlock tables;
create table migtest_e_history5_history(
id integer,
test_number integer,
test_boolean tinyint(1),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
lock tables migtest_e_history5 write;
delimiter $$
create trigger migtest_e_history5_history_upd before update on migtest_e_history5 for each row begin
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number, test_boolean) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number, OLD.test_boolean);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history5_history_del before delete on migtest_e_history5 for each row begin
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number, test_boolean) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number, OLD.test_boolean);
end$$
unlock tables;
create table migtest_e_history6_history(
id integer,
test_number1 integer,
test_number2 integer,
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
lock tables migtest_e_history6 write;
delimiter $$
create trigger migtest_e_history6_history_upd before update on migtest_e_history6 for each row begin
insert into migtest_e_history6_history (sys_period_start,sys_period_end,id, test_number1, test_number2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number1, OLD.test_number2);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history6_history_del before delete on migtest_e_history6 for each row begin
insert into migtest_e_history6_history (sys_period_start,sys_period_end,id, test_number1, test_number2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number1, OLD.test_number2);
end$$
unlock tables;
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,48 @@
-- Inital script to create stored procedures etc for mysql platform
DROP PROCEDURE IF EXISTS usp_ebean_drop_foreign_keys;
delimiter $$
--
-- PROCEDURE: usp_ebean_drop_foreign_keys TABLE, COLUMN
-- deletes all constraints and foreign keys referring to TABLE.COLUMN
--
CREATE PROCEDURE usp_ebean_drop_foreign_keys(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE c_fk_name CHAR(255);
DECLARE curs CURSOR FOR SELECT CONSTRAINT_NAME from information_schema.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = DATABASE() and TABLE_NAME = p_table_name and COLUMN_NAME = p_column_name
AND REFERENCED_TABLE_NAME IS NOT NULL;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN curs;
read_loop: LOOP
FETCH curs INTO c_fk_name;
IF done THEN
LEAVE read_loop;
END IF;
SET @sql = CONCAT('ALTER TABLE ', p_table_name, ' DROP FOREIGN KEY ', c_fk_name);
PREPARE stmt FROM @sql;
EXECUTE stmt;
END LOOP;
CLOSE curs;
END
$$
DROP PROCEDURE IF EXISTS usp_ebean_drop_column;
delimiter $$
--
-- PROCEDURE: usp_ebean_drop_column TABLE, COLUMN
-- deletes the column and ensures that all indices and constraints are dropped first
--
CREATE PROCEDURE usp_ebean_drop_column(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
BEGIN
CALL usp_ebean_drop_foreign_keys(p_table_name, p_column_name);
SET @sql = CONCAT('ALTER TABLE ', p_table_name, ' DROP COLUMN ', p_column_name);
PREPARE stmt FROM @sql;
EXECUTE stmt;
END
$$
@@ -0,0 +1,7 @@
create or replace view order_agg_vw as
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
sum(d.ship_qty * d.unit_price) as ship_total
from o_order_detail d
group by d.order_id
@@ -0,0 +1,4 @@
1835064798, I__create_procs.sql
251257412, 1.0__initial.sql
561281075, R__order_views.sql
@@ -0,0 +1,362 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer auto_increment not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer auto_increment not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint auto_increment not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint auto_increment not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer auto_increment not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date datetime,
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field tinyint(1) default 1 not null,
new_boolean_field2 tinyint(1) default 1 not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer auto_increment not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer auto_increment not null,
test_string bigint comment 'Column altered to long now',
constraint pk_migtest_e_history primary key (id)
) comment='We have history now';
create table migtest_e_history2 (
id integer auto_increment not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer auto_increment not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer auto_increment not null,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer auto_increment not null,
test_number integer,
test_boolean tinyint(1) default 0 not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer auto_increment not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer auto_increment not null,
test_string varchar(255),
deleted tinyint(1) default 0 not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer auto_increment not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer auto_increment not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id bigint auto_increment not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
create table migtest_oto_child (
id integer auto_increment not null,
name varchar(255),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint auto_increment not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- apply alter tables
alter table migtest_e_history add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history add column sys_period_end datetime(6);
alter table migtest_e_history2 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history2 add column sys_period_end datetime(6);
alter table migtest_e_history3 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history3 add column sys_period_end datetime(6);
alter table migtest_e_history4 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history4 add column sys_period_end datetime(6);
alter table migtest_e_history5 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history5 add column sys_period_end datetime(6);
alter table migtest_e_history6 add column sys_period_start datetime(6) default now(6);
alter table migtest_e_history6 add column sys_period_end datetime(6);
-- apply post alter
create table migtest_e_history_history(
id integer,
test_string bigint,
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history;
lock tables migtest_e_history write;
delimiter $$
create trigger migtest_e_history_history_upd before update on migtest_e_history for each row begin
insert into migtest_e_history_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history_history_del before delete on migtest_e_history for each row begin
insert into migtest_e_history_history (sys_period_start,sys_period_end,id, test_string) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string);
end$$
unlock tables;
create table migtest_e_history2_history(
id integer,
test_string varchar(255),
test_string2 varchar(255),
test_string3 varchar(255),
new_column varchar(20),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
lock tables migtest_e_history2 write;
delimiter $$
create trigger migtest_e_history2_history_upd before update on migtest_e_history2 for each row begin
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, new_column) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history2_history_del before delete on migtest_e_history2 for each row begin
insert into migtest_e_history2_history (sys_period_start,sys_period_end,id, test_string, test_string3, new_column) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
end$$
unlock tables;
create table migtest_e_history3_history(
id integer,
test_string varchar(255),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
lock tables migtest_e_history3 write;
delimiter $$
create trigger migtest_e_history3_history_upd before update on migtest_e_history3 for each row begin
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id) values (OLD.sys_period_start, now(6),OLD.id);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history3_history_del before delete on migtest_e_history3 for each row begin
insert into migtest_e_history3_history (sys_period_start,sys_period_end,id) values (OLD.sys_period_start, now(6),OLD.id);
end$$
unlock tables;
create table migtest_e_history4_history(
id integer,
test_number bigint,
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
lock tables migtest_e_history4 write;
delimiter $$
create trigger migtest_e_history4_history_upd before update on migtest_e_history4 for each row begin
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history4_history_del before delete on migtest_e_history4 for each row begin
insert into migtest_e_history4_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
end$$
unlock tables;
create table migtest_e_history5_history(
id integer,
test_number integer,
test_boolean tinyint(1),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
lock tables migtest_e_history5 write;
delimiter $$
create trigger migtest_e_history5_history_upd before update on migtest_e_history5 for each row begin
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number, test_boolean) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number, OLD.test_boolean);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history5_history_del before delete on migtest_e_history5 for each row begin
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number, test_boolean) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number, OLD.test_boolean);
end$$
unlock tables;
create table migtest_e_history6_history(
id integer,
test_number1 integer,
test_number2 integer,
sys_period_start datetime(6),
sys_period_end datetime(6)
);
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
lock tables migtest_e_history6 write;
delimiter $$
create trigger migtest_e_history6_history_upd before update on migtest_e_history6 for each row begin
insert into migtest_e_history6_history (sys_period_start,sys_period_end,id, test_number1, test_number2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number1, OLD.test_number2);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger migtest_e_history6_history_del before delete on migtest_e_history6 for each row begin
insert into migtest_e_history6_history (sys_period_start,sys_period_end,id, test_number1, test_number2) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number1, OLD.test_number2);
end$$
unlock tables;
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,48 @@
-- Inital script to create stored procedures etc for mysql platform
DROP PROCEDURE IF EXISTS usp_ebean_drop_foreign_keys;
delimiter $$
--
-- PROCEDURE: usp_ebean_drop_foreign_keys TABLE, COLUMN
-- deletes all constraints and foreign keys referring to TABLE.COLUMN
--
CREATE PROCEDURE usp_ebean_drop_foreign_keys(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE c_fk_name CHAR(255);
DECLARE curs CURSOR FOR SELECT CONSTRAINT_NAME from information_schema.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = DATABASE() and TABLE_NAME = p_table_name and COLUMN_NAME = p_column_name
AND REFERENCED_TABLE_NAME IS NOT NULL;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN curs;
read_loop: LOOP
FETCH curs INTO c_fk_name;
IF done THEN
LEAVE read_loop;
END IF;
SET @sql = CONCAT('ALTER TABLE ', p_table_name, ' DROP FOREIGN KEY ', c_fk_name);
PREPARE stmt FROM @sql;
EXECUTE stmt;
END LOOP;
CLOSE curs;
END
$$
DROP PROCEDURE IF EXISTS usp_ebean_drop_column;
delimiter $$
--
-- PROCEDURE: usp_ebean_drop_column TABLE, COLUMN
-- deletes the column and ensures that all indices and constraints are dropped first
--
CREATE PROCEDURE usp_ebean_drop_column(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
BEGIN
CALL usp_ebean_drop_foreign_keys(p_table_name, p_column_name);
SET @sql = CONCAT('ALTER TABLE ', p_table_name, ' DROP COLUMN ', p_column_name);
PREPARE stmt FROM @sql;
EXECUTE stmt;
END
$$
@@ -0,0 +1,7 @@
create or replace view order_agg_vw as
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
sum(d.ship_qty * d.unit_price) as ship_total
from o_order_detail d
group by d.order_id
@@ -0,0 +1,4 @@
1835064798, I__create_procs.sql
1129732015, 1.0__initial.sql
561281075, R__order_views.sql
@@ -0,0 +1,233 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id number(10) generated by default as identity not null,
assoc_one varchar2(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id number(10) generated by default as identity not null,
something varchar2(255),
one_key number(10),
two_key varchar2(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key number(10) not null,
two_key varchar2(127) not null,
name varchar2(255),
assoc_id number(10),
version number(10) not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id number(19) generated by default as identity not null,
one_id number(19),
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id number(19) generated by default as identity not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id number(19) generated by default as identity not null,
one_id number(19),
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id number(19) generated by default as identity not null,
one_id number(19),
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id number(19) generated by default as identity not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id number(19) generated by default as identity not null,
one_id number(19),
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id number(10) generated by default as identity not null,
status varchar2(1) default 'A' not null,
status2 varchar2(127),
name varchar2(127),
description varchar2(127),
some_date timestamp,
new_string_field varchar2(255) default 'foo''bar' not null,
new_boolean_field number(1) default 1 not null,
new_boolean_field2 number(1) default 1 not null,
indextest1 varchar2(127),
indextest2 varchar2(127),
indextest3 varchar2(127),
indextest4 varchar2(127),
indextest5 varchar2(127),
indextest6 varchar2(127),
progress number(10) default 0 not null,
new_integer number(10) default 42 not null,
user_id number(10),
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id number(10) generated by default as identity not null,
test_status varchar2(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id number(10) generated by default as identity not null,
test_string number(19),
constraint pk_migtest_e_history primary key (id)
);
comment on table migtest_e_history is 'We have history now';
comment on column migtest_e_history.test_string is 'Column altered to long now';
create table migtest_e_history2 (
id number(10) generated by default as identity not null,
test_string varchar2(255) default 'unknown' not null,
test_string2 varchar2(255),
test_string3 varchar2(255) default 'unknown' not null,
new_column varchar2(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id number(10) generated by default as identity not null,
test_string varchar2(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id number(10) generated by default as identity not null,
test_number number(19),
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id number(10) generated by default as identity not null,
test_number number(10),
test_boolean number(1) default 0 not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id number(10) generated by default as identity not null,
test_number1 number(10) default 42 not null,
test_number2 number(10),
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id number(10) generated by default as identity not null,
test_string varchar2(255),
deleted number(1) default 0 not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id number(10) generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id number(10) generated by default as identity not null,
name varchar2(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id number(10) not null,
migtest_mtm_m_id number(19) not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id number(19) generated by default as identity not null,
name varchar2(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id number(19) not null,
migtest_mtm_c_id number(10) not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id number(19) not null,
value varchar2(255) not null
);
create table migtest_oto_child (
id number(10) generated by default as identity not null,
name varchar2(255),
master_id number(19),
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id number(19) generated by default as identity not null,
name varchar2(255),
constraint pk_migtest_oto_master primary key (id)
);
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key);
create index ix_mgtst_cky_prnt_ssc_d on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_mgtst_cky_prnt_ssc_d foreign key (assoc_id) references migtest_ckey_assoc (id);
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id);
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id);
create index ix_mgtst_fk_nn_v_jn_n_d on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_mgtst_fk_nn_v_jn_n_d foreign key (one_id) references migtest_fk_one (id);
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id);
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id);
create index ix_mgtst_mtm_c_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_mtm_c_mgtst_mt_93awga foreign key (migtest_mtm_c_id) references migtest_mtm_c (id);
create index ix_mgtst_mtm_c_mgtst_mt_3ug4ou on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_mgtst_mtm_c_mgtst_mt_93awgk foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
create index ix_mgtst_mtm_m_mgtst_mt_b7nbcu on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mtm_m_mgtst_mt_ggi34k foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
create index ix_mgtst_mtm_m_mgtst_mt_b7nbck on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mtm_m_mgtst_mt_ggi34a foreign key (migtest_mtm_c_id) references migtest_mtm_c (id);
create index ix_mgtst_mtm_m_phn_nmbr_do9ma3 on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_mgtst_mtm_m_phn_nmbr_s8neid foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id);
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,4 @@
-- oracle only script
select * from dual;
@@ -0,0 +1,7 @@
create or replace view order_agg_vw as
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
sum(d.ship_qty * d.unit_price) as ship_total
from o_order_detail d
group by d.order_id
@@ -0,0 +1,4 @@
1634222133, 1.0__initial.sql
1357801733, R__oracle_only_views.sql
561281075, R__order_views.sql
@@ -0,0 +1,392 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer generated by default as identity not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer generated by default as identity not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer generated by default as identity not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date timestamptz,
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field boolean default true not null,
new_boolean_field2 boolean default true not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer generated by default as identity not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer generated by default as identity not null,
test_string bigint,
constraint pk_migtest_e_history primary key (id)
);
comment on table migtest_e_history is 'We have history now';
comment on column migtest_e_history.test_string is 'Column altered to long now';
create table migtest_e_history2 (
id integer generated by default as identity not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer generated by default as identity not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer generated by default as identity not null,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer generated by default as identity not null,
test_number integer,
test_boolean boolean default false not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer generated by default as identity not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer generated by default as identity not null,
test_string varchar(255),
deleted boolean default false not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
create table migtest_oto_child (
id integer generated by default as identity not null,
name varchar(255),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- apply alter tables
alter table migtest_e_history add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history2 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history3 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history4 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history5 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history6 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
-- apply post alter
create table migtest_e_history_history(like migtest_e_history);
create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history;
create or replace function migtest_e_history_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 migtest_e_history_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history_history_upd
before update or delete on migtest_e_history
for each row execute procedure migtest_e_history_history_version();
create table migtest_e_history2_history(like migtest_e_history2);
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 $$
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 migtest_e_history2_history (sys_period,id, test_string, test_string3, new_column) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history2_history (sys_period,id, test_string, test_string3, new_column) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history2_history_upd
before update or delete on migtest_e_history2
for each row execute procedure migtest_e_history2_history_version();
create table migtest_e_history3_history(like migtest_e_history3);
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
create or replace function migtest_e_history3_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 migtest_e_history3_history (sys_period,id) values (tstzrange(lowerTs,upperTs), OLD.id);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history3_history (sys_period,id) values (tstzrange(lowerTs,upperTs), OLD.id);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history3_history_upd
before update or delete on migtest_e_history3
for each row execute procedure migtest_e_history3_history_version();
create table migtest_e_history4_history(like migtest_e_history4);
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
create or replace function migtest_e_history4_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 migtest_e_history4_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history4_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history4_history_upd
before update or delete on migtest_e_history4
for each row execute procedure migtest_e_history4_history_version();
create table migtest_e_history5_history(like migtest_e_history5);
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
create or replace function migtest_e_history5_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 migtest_e_history5_history (sys_period,id, test_number, test_boolean) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number, OLD.test_boolean);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history5_history (sys_period,id, test_number, test_boolean) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number, OLD.test_boolean);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
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 table migtest_e_history6_history(like migtest_e_history6);
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
create or replace function migtest_e_history6_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 migtest_e_history6_history (sys_period,id, test_number1, test_number2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number1, OLD.test_number2);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history6_history (sys_period,id, test_number1, test_number2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number1, OLD.test_number2);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history6_history_upd
before update or delete on migtest_e_history6
for each row execute procedure migtest_e_history6_history_version();
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
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_migtest_oto_child_name on migtest_oto_child (name);
@@ -0,0 +1,3 @@
-- h2 and postgres script
@@ -0,0 +1,7 @@
create or replace view order_agg_vw as
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
sum(d.ship_qty * d.unit_price) as ship_total
from o_order_detail d
group by d.order_id
@@ -0,0 +1,4 @@
-- postgres specific indexes
create index ix_ebasic_jmjb_gin2 on ebasic_json_map_json_b using gin(content jsonb_path_ops);
@@ -0,0 +1,5 @@
2107694286, 1.0__initial.sql
783227075, R__multi_comments.sql
561281075, R__order_views.sql
283077354, R__pg_indexes.sql
@@ -0,0 +1,206 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id),
foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key),
foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict
);
create table migtest_fk_cascade (
id integer not null,
one_id integer,
constraint pk_migtest_fk_cascade primary key (id),
foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict
);
create table migtest_fk_cascade_one (
id integer not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id integer not null,
one_id integer,
constraint pk_migtest_fk_none primary key (id),
foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict
);
create table migtest_fk_none_via_join (
id integer not null,
one_id integer,
constraint pk_migtest_fk_none_via_join primary key (id),
foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict
);
create table migtest_fk_one (
id integer not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id integer not null,
one_id integer,
constraint pk_migtest_fk_set_null primary key (id),
foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict
);
create table migtest_e_basic (
id integer not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date timestamp,
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field int default 1 not null,
new_boolean_field2 int default 1 not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id),
foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict
);
create table migtest_e_enum (
id integer not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer not null,
test_string integer,
constraint pk_migtest_e_history primary key (id)
);
create table migtest_e_history2 (
id integer not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer not null,
test_number integer,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer not null,
test_number integer,
test_boolean int default 0 not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer not null,
test_string varchar(255),
deleted int default 0 not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id integer not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id),
foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict,
foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict
);
create table migtest_mtm_m (
id integer not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id integer not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id),
foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict,
foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id integer not null,
value varchar(255) not null,
foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict
);
create table migtest_oto_child (
id integer not null,
name varchar(255),
master_id integer,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id),
foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict
);
create table migtest_oto_master (
id integer not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- foreign keys and indices
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,8 @@
drop view if exists order_agg_vw;
create view order_agg_vw as
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
sum(d.ship_qty * d.unit_price) as ship_total
from o_order_detail d
group by d.order_id;
@@ -0,0 +1,3 @@
6725356, 1.0__initial.sql
2034589659, R__order_views_sqlite.sql
@@ -0,0 +1,284 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer not null,
assoc_one nvarchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create sequence migtest_ckey_assoc_seq as bigint start with 1;
create table migtest_ckey_detail (
id integer not null,
something nvarchar(255),
one_key integer,
two_key nvarchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create sequence migtest_ckey_detail_seq as bigint start with 1;
create table migtest_ckey_parent (
one_key integer not null,
two_key nvarchar(127) not null,
name nvarchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id numeric(19) not null,
one_id numeric(19),
constraint pk_migtest_fk_cascade primary key (id)
);
create sequence migtest_fk_cascade_seq as bigint start with 1;
create table migtest_fk_cascade_one (
id numeric(19) not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create sequence migtest_fk_cascade_one_seq as bigint start with 1;
create table migtest_fk_none (
id numeric(19) not null,
one_id numeric(19),
constraint pk_migtest_fk_none primary key (id)
);
create sequence migtest_fk_none_seq as bigint start with 1;
create table migtest_fk_none_via_join (
id numeric(19) not null,
one_id numeric(19),
constraint pk_migtest_fk_none_via_join primary key (id)
);
create sequence migtest_fk_none_via_join_seq as bigint start with 1;
create table migtest_fk_one (
id numeric(19) not null,
constraint pk_migtest_fk_one primary key (id)
);
create sequence migtest_fk_one_seq as bigint start with 1;
create table migtest_fk_set_null (
id numeric(19) not null,
one_id numeric(19),
constraint pk_migtest_fk_set_null primary key (id)
);
create sequence migtest_fk_set_null_seq as bigint start with 1;
create table migtest_e_basic (
id integer not null,
status nvarchar(1) default 'A' not null,
status2 nvarchar(127),
name nvarchar(127),
description nvarchar(127),
some_date datetime2,
new_string_field nvarchar(255) default 'foo''bar' not null,
new_boolean_field bit default 1 not null,
new_boolean_field2 bit default 1 not null,
indextest1 nvarchar(127),
indextest2 nvarchar(127),
indextest3 nvarchar(127),
indextest4 nvarchar(127),
indextest5 nvarchar(127),
indextest6 nvarchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint pk_migtest_e_basic primary key (id)
);
create sequence migtest_e_basic_seq as bigint start with 1;
create table migtest_e_enum (
id integer not null,
test_status nvarchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create sequence migtest_e_enum_seq as bigint start with 1;
create table migtest_e_history (
id integer not null,
test_string numeric(19),
constraint pk_migtest_e_history primary key (id)
);
create sequence migtest_e_history_seq as bigint start with 1;
create table migtest_e_history2 (
id integer not null,
test_string nvarchar(255) default 'unknown' not null,
test_string2 nvarchar(255),
test_string3 nvarchar(255) default 'unknown' not null,
new_column nvarchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create sequence migtest_e_history2_seq as bigint start with 1;
create table migtest_e_history3 (
id integer not null,
test_string nvarchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create sequence migtest_e_history3_seq as bigint start with 1;
create table migtest_e_history4 (
id integer not null,
test_number numeric(19),
constraint pk_migtest_e_history4 primary key (id)
);
create sequence migtest_e_history4_seq as bigint start with 1;
create table migtest_e_history5 (
id integer not null,
test_number integer,
test_boolean bit default 0 not null,
constraint pk_migtest_e_history5 primary key (id)
);
create sequence migtest_e_history5_seq as bigint start with 1;
create table migtest_e_history6 (
id integer not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create sequence migtest_e_history6_seq as bigint start with 1;
create table migtest_e_softdelete (
id integer not null,
test_string nvarchar(255),
deleted bit default 0 not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create sequence migtest_e_softdelete_seq as bigint start with 1;
create table migtest_e_user (
id integer not null,
constraint pk_migtest_e_user primary key (id)
);
create sequence migtest_e_user_seq as bigint start with 1;
create table migtest_mtm_c (
id integer not null,
name nvarchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create sequence migtest_mtm_c_seq as bigint start with 1;
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id numeric(19) not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id numeric(19) not null,
name nvarchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create sequence migtest_mtm_m_seq as bigint start with 1;
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id numeric(19) not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id numeric(19) not null,
value nvarchar(255) not null
);
create table migtest_oto_child (
id integer not null,
name nvarchar(255),
master_id numeric(19),
constraint pk_migtest_oto_child primary key (id)
);
create sequence migtest_oto_child_seq as bigint start with 1;
create table migtest_oto_master (
id numeric(19) not null,
name nvarchar(255),
constraint pk_migtest_oto_master primary key (id)
);
create sequence migtest_oto_master_seq as bigint start with 1;
-- apply post alter
create unique nonclustered index uq_migtest_e_basic_description on migtest_e_basic(description) where description is not null;
create unique nonclustered index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) where indextest1 is not null;
create unique nonclustered index uq_migtest_e_basic_name on migtest_e_basic(name) where name is not null;
create unique nonclustered index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) where indextest4 is not null;
create unique nonclustered index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) where indextest5 is not null;
alter table migtest_e_history
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
period for system_time (sys_periodFrom, sys_periodTo);
alter table migtest_e_history set (system_versioning = on (history_table=dbo.migtest_e_history_history));
alter table migtest_e_history2
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
period for system_time (sys_periodFrom, sys_periodTo);
alter table migtest_e_history2 set (system_versioning = on (history_table=dbo.migtest_e_history2_history));
alter table migtest_e_history3
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
period for system_time (sys_periodFrom, sys_periodTo);
alter table migtest_e_history3 set (system_versioning = on (history_table=dbo.migtest_e_history3_history));
alter table migtest_e_history4
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
period for system_time (sys_periodFrom, sys_periodTo);
alter table migtest_e_history4 set (system_versioning = on (history_table=dbo.migtest_e_history4_history));
alter table migtest_e_history5
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
period for system_time (sys_periodFrom, sys_periodTo);
alter table migtest_e_history5 set (system_versioning = on (history_table=dbo.migtest_e_history5_history));
alter table migtest_e_history6
add sys_periodFrom datetime2 GENERATED ALWAYS AS ROW START NOT NULL DEFAULT SYSUTCDATETIME(),
sys_periodTo datetime2 GENERATED ALWAYS AS ROW END NOT NULL DEFAULT '9999-12-31T23:59:59.9999999',
period for system_time (sys_periodFrom, sys_periodTo);
alter table migtest_e_history6 set (system_versioning = on (history_table=dbo.migtest_e_history6_history));
create unique nonclustered index uq_migtest_oto_child_master_id on migtest_oto_child(master_id) where master_id is not null;
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key);
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id);
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id);
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id);
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id);
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id);
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id);
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);
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id);
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id);
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id);
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,110 @@
-- Initial script to create stored procedures etc for sqlserver platform
-- create table-value-parameters
if not exists (select name from sys.types where name = 'ebean_bigint_tvp') create type ebean_bigint_tvp as table (c1 bigint)
GO
if not exists (select name from sys.types where name = 'ebean_float_tvp') create type ebean_float_tvp as table (c1 float)
GO
if not exists (select name from sys.types where name = 'ebean_bit_tvp') create type ebean_bit_tvp as table (c1 bit)
GO
if not exists (select name from sys.types where name = 'ebean_date_tvp') create type ebean_date_tvp as table (c1 date)
GO
if not exists (select name from sys.types where name = 'ebean_time_tvp') create type ebean_time_tvp as table (c1 time)
GO
if not exists (select name from sys.types where name = 'ebean_uniqueidentifier_tvp') create type ebean_uniqueidentifier_tvp as table (c1 uniqueidentifier)
GO
if not exists (select name from sys.types where name = 'ebean_nvarchar_tvp') create type ebean_nvarchar_tvp as table (c1 nvarchar(max))
GO
--
-- PROCEDURE: usp_ebean_drop_indices TABLE, COLUMN
-- deletes all indices referring to TABLE.COLUMN
--
CREATE OR ALTER PROCEDURE usp_ebean_drop_indices @tableName nvarchar(255), @columnName nvarchar(255)
AS SET NOCOUNT ON
declare @sql nvarchar(1000)
declare @indexName nvarchar(255)
BEGIN
DECLARE index_cursor CURSOR FOR SELECT i.name from sys.indexes i
join sys.index_columns ic on ic.object_id = i.object_id and ic.index_id = i.index_id
join sys.columns c on c.object_id = ic.object_id and c.column_id = ic.column_id
where i.object_id = OBJECT_ID(@tableName) AND c.name = @columnName;
OPEN index_cursor
FETCH NEXT FROM index_cursor INTO @indexName
WHILE @@FETCH_STATUS = 0
BEGIN
set @sql = 'drop index ' + @indexName + ' on ' + @tableName;
EXECUTE(@sql);
FETCH NEXT FROM index_cursor INTO @indexName
END;
CLOSE index_cursor;
DEALLOCATE index_cursor;
END
GO
--
-- PROCEDURE: usp_ebean_drop_default_constraint TABLE, COLUMN
-- deletes the default constraint, which has a random name
--
CREATE OR ALTER PROCEDURE usp_ebean_drop_default_constraint @tableName nvarchar(255), @columnName nvarchar(255)
AS SET NOCOUNT ON
declare @tmp nvarchar(1000)
BEGIN
select @tmp = t1.name from sys.default_constraints t1
join sys.columns t2 on t1.object_id = t2.default_object_id
where t1.parent_object_id = OBJECT_ID(@tableName) and t2.name = @columnName;
if @tmp is not null EXEC('alter table ' + @tableName +' drop constraint ' + @tmp);
END
GO
--
-- PROCEDURE: usp_ebean_drop_constraints TABLE, COLUMN
-- deletes constraints and foreign keys refering to TABLE.COLUMN
--
CREATE OR ALTER PROCEDURE usp_ebean_drop_constraints @tableName nvarchar(255), @columnName nvarchar(255)
AS SET NOCOUNT ON
declare @sql nvarchar(1000)
declare @constraintName nvarchar(255)
BEGIN
DECLARE name_cursor CURSOR FOR
SELECT cc.name from sys.check_constraints cc
join sys.columns c on c.object_id = cc.parent_object_id and c.column_id = cc.parent_column_id
where parent_object_id = OBJECT_ID(@tableName) AND c.name = @columnName
UNION SELECT fk.name from sys.foreign_keys fk
join sys.foreign_key_columns fkc on fkc.constraint_object_id = fk.object_id
and fkc.parent_object_id = fk.parent_object_id
join sys.columns c on c.object_id = fkc.parent_object_id and c.column_id = fkc.parent_column_id
where fkc.parent_object_id = OBJECT_ID(@tableName) AND c.name = @columnName;
OPEN name_cursor
FETCH NEXT FROM name_cursor INTO @constraintName
WHILE @@FETCH_STATUS = 0
BEGIN
set @sql = 'alter table ' + @tableName + ' drop constraint ' + @constraintName;
EXECUTE(@sql);
FETCH NEXT FROM name_cursor INTO @constraintName
END;
CLOSE name_cursor;
DEALLOCATE name_cursor;
END
GO
--
-- PROCEDURE: usp_ebean_drop_column TABLE, COLUMN
-- deletes the column annd ensures that all indices and constraints are dropped first
--
CREATE OR ALTER PROCEDURE usp_ebean_drop_column @tableName nvarchar(255), @columnName nvarchar(255)
AS SET NOCOUNT ON
declare @sql nvarchar(1000)
BEGIN
EXEC usp_ebean_drop_indices @tableName, @columnName;
EXEC usp_ebean_drop_default_constraint @tableName, @columnName;
EXEC usp_ebean_drop_constraints @tableName, @columnName;
set @sql = 'alter table ' + @tableName + ' drop column ' + @columnName;
EXECUTE(@sql);
END
GO
@@ -0,0 +1,10 @@
IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = 'order_agg_vw')
DROP VIEW order_agg_vw;
create view order_agg_vw as
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
sum(d.ship_qty * d.unit_price) as ship_total
from o_order_detail d
group by d.order_id;
@@ -0,0 +1,4 @@
-2122378240, I__create_procs.sql
1625315960, 1.0__initial.sql
1607822082, R__order_views_mssql.sql
@@ -0,0 +1,420 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer generated by default as identity not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer generated by default as identity not null,
something varchar(255),
one_key integer,
two_key varchar(127),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
assoc_id integer,
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer generated by default as identity not null,
status varchar(1) default 'A' not null,
status2 varchar(127),
name varchar(127),
description varchar(127),
some_date timestamptz,
new_string_field varchar(255) default 'foo''bar' not null,
new_boolean_field boolean default true not null,
new_boolean_field2 boolean default true not null,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
progress integer default 0 not null,
new_integer integer default 42 not null,
user_id integer,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?')),
constraint ck_migtest_e_basic_progress check ( progress in (0,1,2)),
constraint uq_migtest_e_basic_description unique (description),
constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1),
constraint uq_migtest_e_basic_name unique (name),
constraint uq_migtest_e_basic_indextest4 unique (indextest4),
constraint uq_migtest_e_basic_indextest5 unique (indextest5),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer generated by default as identity not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer generated by default as identity not null,
test_string bigint,
constraint pk_migtest_e_history primary key (id)
);
comment on table migtest_e_history is 'We have history now';
comment on column migtest_e_history.test_string is 'Column altered to long now';
create table migtest_e_history2 (
id integer generated by default as identity not null,
test_string varchar(255) default 'unknown' not null,
test_string2 varchar(255),
test_string3 varchar(255) default 'unknown' not null,
new_column varchar(20),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer generated by default as identity not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer generated by default as identity not null,
test_number bigint,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer generated by default as identity not null,
test_number integer,
test_boolean boolean default false not null,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer generated by default as identity not null,
test_number1 integer default 42 not null,
test_number2 integer,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_softdelete (
id integer generated by default as identity not null,
test_string varchar(255),
deleted boolean default false not null,
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c (
id integer generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
create table migtest_oto_child (
id integer generated by default as identity not null,
name varchar(255),
master_id bigint,
constraint uq_migtest_oto_child_master_id unique (master_id),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_oto_master primary key (id)
);
-- apply alter tables
alter table migtest_e_history add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history2 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history3 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history4 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history5 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
alter table migtest_e_history6 add column sys_period tstzrange not null default tstzrange(current_timestamp, null);
-- apply post alter
create table migtest_e_history_history(
id integer,
test_string bigint,
sys_period tstzrange
);
create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history;
create or replace function migtest_e_history_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 migtest_e_history_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history_history (sys_period,id, test_string) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history_history_upd
before update or delete on migtest_e_history
for each row execute procedure migtest_e_history_history_version();
create table migtest_e_history2_history(
id integer,
test_string varchar(255),
test_string2 varchar(255),
test_string3 varchar(255),
new_column varchar(20),
sys_period tstzrange
);
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 $$
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 migtest_e_history2_history (sys_period,id, test_string, test_string3, new_column) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history2_history (sys_period,id, test_string, test_string3, new_column) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_string, OLD.test_string3, OLD.new_column);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history2_history_upd
before update or delete on migtest_e_history2
for each row execute procedure migtest_e_history2_history_version();
create table migtest_e_history3_history(
id integer,
test_string varchar(255),
sys_period tstzrange
);
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
create or replace function migtest_e_history3_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 migtest_e_history3_history (sys_period,id) values (tstzrange(lowerTs,upperTs), OLD.id);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history3_history (sys_period,id) values (tstzrange(lowerTs,upperTs), OLD.id);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history3_history_upd
before update or delete on migtest_e_history3
for each row execute procedure migtest_e_history3_history_version();
create table migtest_e_history4_history(
id integer,
test_number bigint,
sys_period tstzrange
);
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
create or replace function migtest_e_history4_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 migtest_e_history4_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history4_history (sys_period,id, test_number) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history4_history_upd
before update or delete on migtest_e_history4
for each row execute procedure migtest_e_history4_history_version();
create table migtest_e_history5_history(
id integer,
test_number integer,
test_boolean boolean,
sys_period tstzrange
);
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
create or replace function migtest_e_history5_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 migtest_e_history5_history (sys_period,id, test_number, test_boolean) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number, OLD.test_boolean);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history5_history (sys_period,id, test_number, test_boolean) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number, OLD.test_boolean);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
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 table migtest_e_history6_history(
id integer,
test_number1 integer,
test_number2 integer,
sys_period tstzrange
);
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
create or replace function migtest_e_history6_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 migtest_e_history6_history (sys_period,id, test_number1, test_number2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number1, OLD.test_number2);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
insert into migtest_e_history6_history (sys_period,id, test_number1, test_number2) values (tstzrange(lowerTs,upperTs), OLD.id, OLD.test_number1, OLD.test_number2);
return old;
end if;
end;
$$ LANGUAGE plpgsql;
create trigger migtest_e_history6_history_upd
before update or delete on migtest_e_history6
for each row execute procedure migtest_e_history6_history_version();
-- foreign keys and indices
create index ix_migtest_ckey_detail_parent on migtest_ckey_detail (one_key,two_key);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_one_id on migtest_fk_none (one_id);
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_none_via_join_one_id on migtest_fk_none_via_join (one_id);
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_user_id on migtest_e_basic (user_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
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);
@@ -0,0 +1,7 @@
create or replace view order_agg_vw as
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
sum(d.ship_qty * d.unit_price) as ship_total
from o_order_detail d
group by d.order_id
@@ -0,0 +1,3 @@
964249682, 1.0__initial.sql
561281075, R__order_views.sql
@@ -1,68 +0,0 @@
package io.ebeaninternal.dbmigration;
import io.ebean.DatabaseFactory;
import io.ebean.config.DatabaseConfig;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Class to test the alternative drop behaviour using stored procedures for MySql databases .
*
* @author Jonas P&ouml;hler, FOCONIS AG
*/
public class MysqlGenerateMigrationTest {
@Test
public void testMysqlStoredProcedures() throws Exception {
String pathToResources = "src/test/resources";
DatabaseConfig config = new DatabaseConfig();
config.setName("migrationtest");
config.loadFromProperties();
config.setRegister(false);
config.setDefaultServer(false);
config.getPlatformConfig().setUseMigrationStoredProcedures(true);
config.setRunMigration(false);
config.getProperties().put("ebean.migrationtest.migration.pathToResources", pathToResources);
config.getProperties().put("ebean.migrationtest.migration.platforms", "mysql");
config.getProperties().put("ebean.migrationtest.migration.migrationPath", "migrationtest-procedures/dbmigration");
config.getProperties().put("ebean.migrationtest.migration.migrationInitPath", "migrationtest-procedures/dbinit");
config.setPackages(Arrays.asList("misc.migration.mysql_v1_0"));
// First, we clean up the output-directory
Path path = Paths.get(pathToResources , "migrationtest-procedures");
Files.walk(path)
.filter(Files::isRegularFile).map(Path::toFile).forEach(File::delete);
DatabaseFactory.create(config).shutdown();
// then we generate migration scripts for v1_0
assertThat(DbMigrationPlugin.getLastMigration()).isEqualTo("1.0__initial");
assertThat(DbMigrationPlugin.getLastInit()).isEqualTo("1.0__initial");
// and now for v1_1
config.setPackages(Arrays.asList("misc.migration.mysql_v1_1"));
DatabaseFactory.create(config).shutdown();
assertThat(DbMigrationPlugin.getLastMigration()).isEqualTo("1.1,1.2__dropsFor_1.1");
assertThat(DbMigrationPlugin.getLastInit()).isEqualTo("1.2");
final Path sqlFile = path.resolve("dbmigration/mysql/1.2__dropsFor_1.1.sql");
assertThat(sqlFile).isNotEmptyFile();
assertThat(Files.readAllLines(sqlFile, StandardCharsets.UTF_8))
.contains("CALL usp_ebean_drop_column('migtest_e_basic', 'status2');")
.contains("CALL usp_ebean_drop_column('migtest_e_basic', 'description');");
}
}
@@ -1,89 +0,0 @@
package misc.migration.mysql_v1_0;
import io.ebean.annotation.DbDefault;
import io.ebean.annotation.EnumValue;
import io.ebean.annotation.NotNull;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Size;
@Entity
@Table(name = "migtest_e_basic")
public class EBasic {
public enum Status {
@EnumValue("N")
NEW,
@EnumValue("A")
ACTIVE,
@EnumValue("I")
INACTIVE,
}
@Id
Integer id;
Status status;
@DbDefault("N")
@NotNull
Status status2;
@Size(max=127)
String name;
@Size(max=127)
String description;
public EBasic() {
}
public EBasic(String name) {
this.name = name;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Status getStatus2() {
return status2;
}
public void setStatus2(final Status status2) {
this.status2 = status2;
}
}
@@ -1,64 +0,0 @@
package misc.migration.mysql_v1_1;
import io.ebean.annotation.EnumValue;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.validation.constraints.Size;
@Entity
@Table(name = "migtest_e_basic")
public class EBasic {
public enum Status {
@EnumValue("N")
NEW,
@EnumValue("A")
ACTIVE,
@EnumValue("I")
INACTIVE,
}
@Id
Integer id;
Status status;
@Size(max=127)
String name;
public EBasic() {
}
public EBasic(String name) {
this.name = name;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public Status getStatus() {
return status;
}
public void setStatus(Status status) {
this.status = status;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
@@ -0,0 +1,135 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id UInt32,
assoc_one String
) ENGINE = Log();
create table migtest_ckey_detail (
id UInt32,
something String
) ENGINE = Log();
create table migtest_ckey_parent (
one_key UInt32,
two_key String,
name String,
version UInt32
) ENGINE = Log();
create table migtest_fk_cascade (
id UInt64,
one_id UInt64
) ENGINE = Log();
create table migtest_fk_cascade_one (
id UInt64
) ENGINE = Log();
create table migtest_fk_none (
id UInt64,
one_id UInt64
) ENGINE = Log();
create table migtest_fk_none_via_join (
id UInt64,
one_id UInt64
) ENGINE = Log();
create table migtest_fk_one (
id UInt64
) ENGINE = Log();
create table migtest_fk_set_null (
id UInt64,
one_id UInt64
) ENGINE = Log();
create table migtest_e_basic (
id UInt32,
status String,
status2 String default 'N',
name String,
description String,
description_file blob,
some_date DateTime,
old_boolean UInt8 default 0,
old_boolean2 UInt8,
eref_id UInt32,
indextest1 String,
indextest2 String,
indextest3 String,
indextest4 String,
indextest5 String,
indextest6 String,
user_id UInt32
) ENGINE = Log();
create table migtest_e_enum (
id UInt32,
test_status String
) ENGINE = Log();
create table migtest_e_history (
id UInt32,
test_string String
) ENGINE = Log();
create table migtest_e_history2 (
id UInt32,
test_string String,
obsolete_string1 String,
obsolete_string2 String
) ENGINE = Log();
create table migtest_e_history3 (
id UInt32,
test_string String
) ENGINE = Log();
create table migtest_e_history4 (
id UInt32,
test_number UInt32
) ENGINE = Log();
create table migtest_e_history5 (
id UInt32,
test_number UInt32
) ENGINE = Log();
create table migtest_e_history6 (
id UInt32,
test_number1 UInt32,
test_number2 UInt32
) ENGINE = Log();
create table migtest_e_ref (
id UInt32,
name String
) ENGINE = Log();
create table migtest_e_softdelete (
id UInt32,
test_string String
) ENGINE = Log();
create table migtest_mtm_c (
id UInt32,
name String
) ENGINE = Log();
create table migtest_mtm_m (
id UInt64,
name String
) ENGINE = Log();
create table migtest_oto_child (
id UInt32,
name String
) ENGINE = Log();
create table migtest_oto_master (
id UInt64,
name String
) ENGINE = Log();
@@ -0,0 +1,78 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status;
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
-- apply changes
create table migtest_e_user (
id UInt32
) ENGINE = Log();
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id UInt32,
migtest_mtm_m_id UInt64
) ENGINE = Log();
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id UInt64,
migtest_mtm_c_id UInt32
) ENGINE = Log();
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id UInt64,
value String
) ENGINE = Log();
update migtest_e_basic set status = 'A' where status is null;
-- rename all collisions;
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;
-- 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 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;
alter table migtest_e_basic alter column status set default 'A';
alter table migtest_e_basic alter column status set not null;
alter table migtest_e_basic alter column status2 String;
alter table migtest_e_basic alter column status2 drop default;
alter table migtest_e_basic alter column status2 set null;
alter table migtest_e_basic alter column user_id set null;
alter table migtest_e_basic add column new_string_field String default 'foo''bar';
alter table migtest_e_basic add column new_boolean_field UInt8 default 1;
alter table migtest_e_basic add column new_boolean_field2 UInt8 default 1;
alter table migtest_e_basic add column progress UInt32 default 0;
alter table migtest_e_basic add column new_integer UInt32 default 42;
alter table migtest_e_history alter column test_string UInt64;
alter table migtest_e_history2 alter column test_string set default 'unknown';
alter table migtest_e_history2 alter column test_string set not null;
alter table migtest_e_history2 add column test_string2 String;
alter table migtest_e_history2 add column test_string3 String default 'unknown';
alter table migtest_e_history2 add column new_column String;
alter table migtest_e_history4 alter column test_number UInt64;
alter table migtest_e_history5 add column test_boolean UInt8 default 0;
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 set null;
alter table migtest_e_softdelete add column deleted UInt8 default 0;
alter table migtest_oto_child add column master_id UInt64;
-- 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);
-- NOTE: table has @History - special migration may be necessary
update migtest_e_basic set new_boolean_field = old_boolean;
alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2));
alter table migtest_e_basic add constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1);
alter table migtest_e_basic add constraint uq_migtest_e_basic_name unique (name);
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest4 unique (indextest4);
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique (indextest5);
@@ -0,0 +1,10 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
alter table migtest_e_basic drop column description_file;
alter table migtest_e_basic drop column old_boolean;
alter table migtest_e_basic drop column old_boolean2;
alter table migtest_e_basic drop column eref_id;
alter table migtest_e_history2 drop column obsolete_string1;
alter table migtest_e_history2 drop column obsolete_string2;
-- apply post alter
drop table if exists migtest_e_ref;
@@ -0,0 +1,50 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status;
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_description;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_name;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
-- apply changes
create table migtest_e_ref (
id UInt32,
name String
) ENGINE = Log();
update migtest_e_basic set status2 = 'N' where status2 is null;
update migtest_e_basic set user_id = 23 where user_id is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
-- apply alter tables
alter table migtest_e_basic alter column status drop default;
alter table migtest_e_basic alter column status set null;
alter table migtest_e_basic alter column status2 String;
alter table migtest_e_basic alter column status2 set default 'N';
alter table migtest_e_basic alter column status2 set not null;
alter table migtest_e_basic alter column user_id set default 23;
alter table migtest_e_basic alter column user_id set not null;
alter table migtest_e_basic add column description_file blob;
alter table migtest_e_basic add column old_boolean UInt8 default 0;
alter table migtest_e_basic add column old_boolean2 UInt8;
alter table migtest_e_basic add column eref_id UInt32;
alter table migtest_e_history2 alter column test_string drop default;
alter table migtest_e_history2 alter column test_string set null;
alter table migtest_e_history2 add column obsolete_string1 String;
alter table migtest_e_history2 add column obsolete_string2 String;
alter table migtest_e_history4 alter column test_number UInt32;
alter table migtest_e_history6 alter column test_number1 drop default;
alter table migtest_e_history6 alter column test_number1 set 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;
-- 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 ck_migtest_e_basic_status2 check ( status2 in ('N','A','I'));
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest2 unique (indextest2);
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest6 unique (indextest6);
alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I'));
@@ -0,0 +1,21 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
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;
alter table migtest_e_basic drop column new_string_field;
alter table migtest_e_basic drop column new_boolean_field;
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;
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;
alter table migtest_e_history5 drop column test_boolean;
alter table migtest_e_softdelete drop column deleted;
alter table migtest_oto_child drop column master_id;
-- apply post alter
drop table if exists migtest_e_user;
drop table if exists migtest_mtm_c_migtest_mtm_m;
drop table if exists migtest_mtm_m_migtest_mtm_c;
drop table if exists migtest_mtm_m_phone_numbers;
@@ -0,0 +1,6 @@
1588846231, 1.0__initial.sql
-1102375855, 1.1.sql
1279151426, 1.2__dropsFor_1.1.sql
581928632, 1.3.sql
80209848, 1.4__dropsFor_1.3.sql
@@ -60,8 +60,8 @@ create table migtest_e_basic (
status2 varchar(1) default 'N' not null,
name varchar(127),
description varchar(127),
description_file blob(64M),
some_date timestamp,
description_file bytea,
some_date timestamptz,
old_boolean boolean default false not null,
old_boolean2 boolean,
eref_id integer,
@@ -71,13 +71,13 @@ create table migtest_e_basic (
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
user_id integer default 23 not null,
user_id integer not null,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I')),
constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')),
constraint uq_migtest_e_basic_indextest2 unique (indextest2),
constraint uq_migtest_e_basic_indextest6 unique (indextest6),
constraint pk_migtest_e_basic primary key (id)
);
create 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_enum (
id integer generated by default as identity not null,
@@ -88,7 +88,7 @@ create table migtest_e_enum (
create table migtest_e_history (
id integer generated by default as identity not null,
test_string bigint,
test_string varchar(255),
constraint pk_migtest_e_history primary key (id)
);
@@ -121,16 +121,16 @@ create table migtest_e_history5 (
create table migtest_e_history6 (
id integer generated by default as identity not null,
test_number1 integer,
test_number2 integer default 7 not null,
test_number2 integer not null,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_ref (
id integer generated by default as identity not null,
name varchar(127) not null,
constraint uq_migtest_e_ref_name unique (name),
constraint pk_migtest_e_ref primary key (id)
);
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);
create table migtest_e_softdelete (
id integer generated by default as identity not null,
@@ -162,14 +162,15 @@ create table migtest_oto_master (
constraint pk_migtest_oto_master primary key (id)
);
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
-- foreign keys and indices
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null;
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict;
create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict;
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
@@ -0,0 +1,114 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
alter table if exists migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
alter table if exists migtest_fk_set_null drop constraint if exists fk_migtest_fk_set_null_one_id;
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status;
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2;
drop index uq_migtest_e_basic_indextest2 cascade;
drop index uq_migtest_e_basic_indextest6 cascade;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest1;
drop index if exists ix_migtest_e_basic_indextest5;
-- apply changes
create table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
update migtest_e_basic set status = 'A' where status is null;
-- rename all collisions;
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;
-- 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 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;
alter table migtest_e_basic alter column status set default 'A';
alter table migtest_e_basic alter column status set not null;
alter table migtest_e_basic alter column status2 type varchar(127);
alter table migtest_e_basic alter column status2 drop default;
alter table migtest_e_basic alter column status2 drop not null;
alter table migtest_e_basic alter column user_id drop not null;
alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null;
alter table migtest_e_basic add column new_boolean_field boolean default true not null;
alter table migtest_e_basic add column new_boolean_field2 boolean default true not null;
alter table migtest_e_basic add column progress integer default 0 not null;
alter table migtest_e_basic add column new_integer integer default 42 not null;
alter table migtest_e_history alter column test_string type bigint;
alter table migtest_e_history2 alter column test_string set default 'unknown';
alter table migtest_e_history2 alter column test_string set not null;
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);
alter table migtest_e_history4 alter column test_number type bigint;
alter table migtest_e_history5 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;
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
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);
-- NOTE: table has @History - special migration may be necessary
update migtest_e_basic set new_boolean_field = old_boolean;
alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2));
alter table migtest_e_basic add constraint uq_migtest_e_basic_status_indextest1 unique (status,indextest1);
alter table migtest_e_basic add constraint uq_migtest_e_basic_name unique (name);
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest4 unique (indextest4);
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest5 unique (indextest5);
-- 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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict 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 restrict on update restrict;
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,11 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
alter table migtest_e_basic drop column description_file;
alter table migtest_e_basic drop column old_boolean;
alter table migtest_e_basic drop column old_boolean2;
alter table migtest_e_basic drop column eref_id;
alter table migtest_e_history2 drop column obsolete_string1;
alter table migtest_e_history2 drop column obsolete_string2;
-- apply post alter
drop table if exists migtest_e_ref cascade;
drop sequence if exists migtest_e_ref_seq;
@@ -0,0 +1,68 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
alter table if exists migtest_ckey_detail drop constraint if exists fk_migtest_ckey_detail_parent;
alter table if exists migtest_fk_cascade drop constraint if exists fk_migtest_fk_cascade_one_id;
alter table if exists migtest_fk_none drop constraint if exists fk_migtest_fk_none_one_id;
alter table if exists migtest_fk_none_via_join drop constraint if exists fk_migtest_fk_none_via_join_one_id;
alter table if exists migtest_fk_set_null drop constraint if exists fk_migtest_fk_set_null_one_id;
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status;
alter table migtest_e_basic drop constraint if exists ck_migtest_e_basic_status2;
drop index uq_migtest_e_basic_description cascade;
alter table if exists migtest_e_basic drop constraint if exists fk_migtest_e_basic_user_id;
drop index uq_migtest_e_basic_status_indextest1 cascade;
drop index uq_migtest_e_basic_name cascade;
drop index uq_migtest_e_basic_indextest4 cascade;
drop index uq_migtest_e_basic_indextest5 cascade;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
-- apply changes
create table migtest_e_ref (
id integer generated by default as identity not null,
name varchar(127) not null,
constraint uq_migtest_e_ref_name unique (name),
constraint pk_migtest_e_ref primary key (id)
);
update migtest_e_basic set status2 = 'N' where status2 is null;
update migtest_e_basic set user_id = 23 where user_id is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
-- apply alter tables
alter table migtest_e_basic alter column status drop default;
alter table migtest_e_basic alter column status drop not null;
alter table migtest_e_basic alter column status2 type varchar(1);
alter table migtest_e_basic alter column status2 set default 'N';
alter table migtest_e_basic alter column status2 set not null;
alter table migtest_e_basic alter column user_id set default 23;
alter table migtest_e_basic alter column user_id set not null;
alter table migtest_e_basic add column description_file bytea;
alter table migtest_e_basic add column old_boolean boolean default false not null;
alter table migtest_e_basic add column old_boolean2 boolean;
alter table migtest_e_basic add column eref_id integer;
alter table migtest_e_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_history4 alter column test_number type integer;
alter table migtest_e_history6 alter column test_number1 drop default;
alter table migtest_e_history6 alter column test_number1 drop not null;
alter table migtest_e_history6 alter column test_number2 set default 7;
alter table migtest_e_history6 alter column test_number2 set not null;
-- 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 ck_migtest_e_basic_status2 check ( status2 in ('N','A','I'));
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest2 unique (indextest2);
alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest6 unique (indextest6);
alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I'));
-- 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;
create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
@@ -0,0 +1,22 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
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;
alter table migtest_e_basic drop column new_string_field;
alter table migtest_e_basic drop column new_boolean_field;
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;
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;
alter table migtest_e_history5 drop column test_boolean;
alter table migtest_e_softdelete drop column deleted;
alter table migtest_oto_child drop column master_id;
-- apply post alter
drop table if exists migtest_e_user cascade;
drop sequence if exists migtest_e_user_seq;
drop table if exists migtest_mtm_c_migtest_mtm_m cascade;
drop table if exists migtest_mtm_m_migtest_mtm_c cascade;
drop table if exists migtest_mtm_m_phone_numbers cascade;
@@ -0,0 +1,7 @@
create or replace view order_agg_vw as
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
sum(d.ship_qty * d.unit_price) as ship_total
from o_order_detail d
group by d.order_id
@@ -0,0 +1,7 @@
246318791, 1.0__initial.sql
1109849447, 1.1.sql
240919209, 1.2__dropsFor_1.1.sql
612721597, 1.3.sql
-820814009, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql
@@ -0,0 +1,241 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer generated by default as identity not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer generated by default as identity not null,
something varchar(255),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer generated by default as identity not null,
status varchar(1),
status2 varchar(1) default 'N' not null,
name varchar(127),
description varchar(127),
description_file blob(64M),
some_date timestamp,
old_boolean smallint default 0 default false not null,
old_boolean2 smallint default 0,
eref_id integer,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
user_id integer not null,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I')),
constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer generated by default as identity not null,
test_status varchar(1),
constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer generated by default as identity not null,
test_string varchar(255),
constraint pk_migtest_e_history primary key (id)
);
create table migtest_e_history2 (
id integer generated by default as identity not null,
test_string varchar(255),
obsolete_string1 varchar(255),
obsolete_string2 varchar(255),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer generated by default as identity not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer generated by default as identity not null,
test_number integer,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer generated by default as identity not null,
test_number integer,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer generated by default as identity not null,
test_number1 integer,
test_number2 integer not null,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_ref (
id integer generated by default as identity not null,
name varchar(127) not null,
constraint pk_migtest_e_ref primary key (id)
);
create table migtest_e_softdelete (
id integer generated by default as identity not null,
test_string varchar(255),
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_mtm_c (
id integer generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_m (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_oto_child (
id integer generated by default as identity not null,
name varchar(255),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint generated by default as identity not null,
name varchar(255),
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);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict;
create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
@@ -0,0 +1,223 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_CASCADE_ONE_ID' and tabname = 'MIGTEST_FK_CASCADE') then
prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_SET_NULL_ONE_ID' and tabname = 'MIGTEST_FK_SET_NULL') then
prepare stmt from 'alter table migtest_fk_set_null drop constraint fk_migtest_fk_set_null_one_id';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS2' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_INDEXTEST2' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_INDEXTEST2') then
prepare stmt from 'drop index uq_migtest_e_basic_indextest2';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_INDEXTEST6' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_INDEXTEST6') then
prepare stmt from 'drop index uq_migtest_e_basic_indextest6';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_ENUM_TEST_STATUS' and tabname = 'MIGTEST_E_ENUM') then
prepare stmt from 'alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST1') then
prepare stmt from 'drop index ix_migtest_e_basic_indextest1';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST5') then
prepare stmt from 'drop index ix_migtest_e_basic_indextest5';
execute stmt;
end if;
end$$;
-- apply changes
create table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
update migtest_e_basic set status = 'A' where status is null;
-- db2 does not support parial null indices :( - so we have to clean;
update migtest_e_basic set status = 'N' where id = 1;
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);
alter table migtest_ckey_parent add column assoc_id integer;
alter table migtest_e_basic alter column status set default 'A';
alter table migtest_e_basic alter column status set not null;
alter table migtest_e_basic alter column status2 set data type varchar(127);
alter table migtest_e_basic alter column status2 drop default;
alter table migtest_e_basic alter column status2 drop not null;
alter table migtest_e_basic alter column user_id drop not null;
alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null;
alter table migtest_e_basic add column new_boolean_field smallint default 0 default true not null;
alter table migtest_e_basic add column new_boolean_field2 smallint default 0 default true not null;
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';
alter table migtest_e_history2 alter column test_string set not null;
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
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;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_basic set new_boolean_field = old_boolean;
alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2));
create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) exclude null keys;
create unique index uq_migtest_e_basic_name on migtest_e_basic(name) exclude null keys;
create unique index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) exclude null keys;
create unique index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) exclude null keys;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict 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 restrict on update restrict;
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,25 @@
-- 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;
alter table migtest_e_basic drop column old_boolean2;
alter table migtest_e_basic drop column eref_id;
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
if exists (select seqschema from syscat.sequences where seqschema = current_schema and seqname = 'MIGTEST_E_REF_SEQ') then
prepare stmt from 'drop sequence migtest_e_ref_seq';
execute stmt;
end if;
end$$;
@@ -0,0 +1,220 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_CKEY_DETAIL_PARENT' and tabname = 'MIGTEST_CKEY_DETAIL') then
prepare stmt from 'alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_CASCADE_ONE_ID' and tabname = 'MIGTEST_FK_CASCADE') then
prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_NONE_ONE_ID' and tabname = 'MIGTEST_FK_NONE') then
prepare stmt from 'alter table migtest_fk_none drop constraint fk_migtest_fk_none_one_id';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_NONE_VIA_JOIN_ONE_ID' and tabname = 'MIGTEST_FK_NONE_VIA_JOIN') then
prepare stmt from 'alter table migtest_fk_none_via_join drop constraint fk_migtest_fk_none_via_join_one_id';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_SET_NULL_ONE_ID' and tabname = 'MIGTEST_FK_SET_NULL') then
prepare stmt from 'alter table migtest_fk_set_null drop constraint fk_migtest_fk_set_null_one_id';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS2' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_DESCRIPTION' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_description';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_DESCRIPTION') then
prepare stmt from 'drop index uq_migtest_e_basic_description';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_E_BASIC_USER_ID' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint fk_migtest_e_basic_user_id';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_STATUS_INDEXTEST1' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_STATUS_INDEXTEST1') then
prepare stmt from 'drop index uq_migtest_e_basic_status_indextest1';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_NAME' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_name';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_NAME') then
prepare stmt from 'drop index uq_migtest_e_basic_name';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_INDEXTEST4' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_INDEXTEST4') then
prepare stmt from 'drop index uq_migtest_e_basic_indextest4';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_INDEXTEST5' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_INDEXTEST5') then
prepare stmt from 'drop index uq_migtest_e_basic_indextest5';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_ENUM_TEST_STATUS' and tabname = 'MIGTEST_E_ENUM') then
prepare stmt from 'alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST3') then
prepare stmt from 'drop index ix_migtest_e_basic_indextest3';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST6') then
prepare stmt from 'drop index ix_migtest_e_basic_indextest6';
execute stmt;
end if;
end$$;
-- apply changes
create table migtest_e_ref (
id integer generated by default as identity not null,
name varchar(127) not null,
constraint pk_migtest_e_ref primary key (id)
);
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;
-- apply alter tables
alter table migtest_e_basic alter column status drop default;
alter table migtest_e_basic alter column status drop not null;
alter table migtest_e_basic alter column status2 set data type varchar(1);
alter table migtest_e_basic alter column status2 set default 'N';
alter table migtest_e_basic alter column status2 set not null;
alter table migtest_e_basic alter column user_id set default 23;
alter table migtest_e_basic alter column user_id set not null;
alter table migtest_e_basic add column description_file blob(64M);
alter table migtest_e_basic add column old_boolean smallint default 0 default false not null;
alter table migtest_e_basic add column old_boolean2 smallint default 0;
alter table migtest_e_basic add column eref_id integer;
call sysproc.admin_cmd('reorg table migtest_e_basic');
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'));
alter table migtest_e_basic add constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I'));
create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys;
create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) exclude null keys;
alter table migtest_e_enum 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;
create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
@@ -0,0 +1,53 @@
-- 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;
call sysproc.admin_cmd('reorg table migtest_ckey_detail');
alter table migtest_ckey_parent drop column assoc_id;
call sysproc.admin_cmd('reorg table migtest_ckey_parent');
alter table migtest_e_basic drop column new_string_field;
alter table migtest_e_basic drop column new_boolean_field;
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
if exists (select seqschema from syscat.sequences where seqschema = current_schema and seqname = 'MIGTEST_E_USER_SEQ') then
prepare stmt from 'drop sequence migtest_e_user_seq';
execute stmt;
end if;
end$$;
drop table migtest_mtm_c_migtest_mtm_m;
drop table migtest_mtm_m_migtest_mtm_c;
drop table migtest_mtm_m_phone_numbers;
@@ -0,0 +1,7 @@
create or replace view order_agg_vw as
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
sum(d.ship_qty * d.unit_price) as ship_total
from o_order_detail d
group by d.order_id
@@ -0,0 +1,7 @@
-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
@@ -0,0 +1,241 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer generated by default as identity not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer generated by default as identity not null,
something varchar(255),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint generated by default as identity not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint generated by default as identity not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer generated by default as identity not null,
status varchar(1),
status2 varchar(1) default 'N' not null,
name varchar(127),
description varchar(127),
description_file blob(64M),
some_date timestamp,
old_boolean boolean default false not null,
old_boolean2 boolean,
eref_id integer,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
user_id integer not null,
constraint ck_mgtst__bsc_stts check ( status in ('N','A','I')),
constraint ck_mgtst__b_z543fg check ( status2 in ('N','A','I')),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer generated by default as identity not null,
test_status varchar(1),
constraint ck_mgtst__n_773sok check ( test_status in ('N','A','I')),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer generated by default as identity not null,
test_string varchar(255),
constraint pk_migtest_e_history primary key (id)
);
create table migtest_e_history2 (
id integer generated by default as identity not null,
test_string varchar(255),
obsolete_string1 varchar(255),
obsolete_string2 varchar(255),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer generated by default as identity not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer generated by default as identity not null,
test_number integer,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer generated by default as identity not null,
test_number integer,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer generated by default as identity not null,
test_number1 integer,
test_number2 integer not null,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_ref (
id integer generated by default as identity not null,
name varchar(127) not null,
constraint pk_migtest_e_ref primary key (id)
);
create table migtest_e_softdelete (
id integer generated by default as identity not null,
test_string varchar(255),
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_mtm_c (
id integer generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_m (
id bigint generated by default as identity not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_oto_child (
id integer generated by default as identity not null,
name varchar(255),
constraint pk_migtest_oto_child primary key (id)
);
create table migtest_oto_master (
id bigint generated by default as identity not null,
name varchar(255),
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);
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;
create index ix_mgtst_fk_c4p3mv on migtest_fk_set_null (one_id);
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;
create index ix_mgtst__bsc_rf_d on migtest_e_basic (eref_id);
alter table migtest_e_basic add constraint fk_mgtst__bsc_rf_d foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
create index ix_mgtst__b_eu8csq on migtest_e_basic (indextest1);
create index ix_mgtst__b_eu8csu on migtest_e_basic (indextest5);
@@ -0,0 +1,223 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MGTST_FK_65KF6L' and tabname = 'MIGTEST_FK_CASCADE') then
prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MGTST_FK_WICX8X' and tabname = 'MIGTEST_FK_SET_NULL') then
prepare stmt from 'alter table migtest_fk_set_null drop constraint fk_mgtst_fk_wicx8x';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MGTST__BSC_STTS' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_mgtst__bsc_stts';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MGTST__B_Z543FG' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_mgtst__b_z543fg';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MGTST__B_4AYBZY' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_mgtst__b_4aybzy';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MGTST__B_4AYBZY') then
prepare stmt from 'drop index uq_mgtst__b_4aybzy';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MGTST__B_4AYC02' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc02';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MGTST__B_4AYC02') then
prepare stmt from 'drop index uq_mgtst__b_4ayc02';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MGTST__N_773SOK' and tabname = 'MIGTEST_E_ENUM') then
prepare stmt from 'alter table migtest_e_enum drop constraint ck_mgtst__n_773sok';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MGTST__B_EU8CSQ') then
prepare stmt from 'drop index ix_mgtst__b_eu8csq';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MGTST__B_EU8CSU') then
prepare stmt from 'drop index ix_mgtst__b_eu8csu';
execute stmt;
end if;
end$$;
-- apply changes
create table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
update migtest_e_basic set status = 'A' where status is null;
-- db2 does not support parial null indices :( - so we have to clean;
update migtest_e_basic set status = 'N' where id = 1;
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);
alter table migtest_ckey_parent add column assoc_id integer;
alter table migtest_e_basic alter column status set default 'A';
alter table migtest_e_basic alter column status set not null;
alter table migtest_e_basic alter column status2 set data type varchar(127);
alter table migtest_e_basic alter column status2 drop default;
alter table migtest_e_basic alter column status2 drop not null;
alter table migtest_e_basic alter column user_id drop not null;
alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null;
alter table migtest_e_basic add column new_boolean_field boolean default true not null;
alter table migtest_e_basic add column new_boolean_field2 boolean default true not null;
alter table migtest_e_basic add column progress integer default 0 not null;
alter table migtest_e_basic add 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';
alter table migtest_e_history2 alter column test_string set not null;
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
alter table migtest_e_basic add constraint ck_mgtst__bsc_stts check ( status in ('N','A','I','?'));
create unique index uq_mgtst__b_vs45xo on migtest_e_basic(description) exclude null keys;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_basic set new_boolean_field = old_boolean;
alter table migtest_e_basic add constraint ck_mgtst__b_l39g41 check ( progress in (0,1,2));
create unique index uq_mgtst__b_ucfcne on migtest_e_basic(status,indextest1) exclude null keys;
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;
create index ix_mgtst_mt_3ug4ou on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_mgtst_mt_93awgk foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_mgtst_mt_b7nbcu on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mt_ggi34k foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_mgtst_mt_b7nbck on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_mgtst_mt_ggi34a foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_mgtst_mt_do9ma3 on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_mgtst_mt_s8neid foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_ckey_detail add constraint fk_mgtst_ck_e1qkb5 foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_mgtst_ck_x45o21 on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_mgtst_ck_da00mr foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
alter table migtest_fk_cascade add constraint fk_mgtst_fk_65kf6l foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
alter table migtest_fk_none add constraint fk_mgtst_fk_nn_n_d foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
alter table migtest_fk_none_via_join add constraint fk_mgtst_fk_9tknzj foreign key (one_id) references migtest_fk_one (id) on delete restrict 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 restrict on update restrict;
alter table migtest_e_basic add constraint fk_mgtst__bsc_sr_d foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_mgtst_t__csyl38 foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_mgtst__b_eu8css on migtest_e_basic (indextest3);
create index ix_mgtst__b_eu8csv on migtest_e_basic (indextest6);
@@ -0,0 +1,25 @@
-- 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;
alter table migtest_e_basic drop column old_boolean2;
alter table migtest_e_basic drop column eref_id;
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
if exists (select seqschema from syscat.sequences where seqschema = current_schema and seqname = 'MIGTEST_E_REF_SEQ') then
prepare stmt from 'drop sequence migtest_e_ref_seq';
execute stmt;
end if;
end$$;
@@ -0,0 +1,220 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MGTST_CK_E1QKB5' and tabname = 'MIGTEST_CKEY_DETAIL') then
prepare stmt from 'alter table migtest_ckey_detail drop constraint fk_mgtst_ck_e1qkb5';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MGTST_FK_65KF6L' and tabname = 'MIGTEST_FK_CASCADE') then
prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MGTST_FK_NN_N_D' and tabname = 'MIGTEST_FK_NONE') then
prepare stmt from 'alter table migtest_fk_none drop constraint fk_mgtst_fk_nn_n_d';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MGTST_FK_9TKNZJ' and tabname = 'MIGTEST_FK_NONE_VIA_JOIN') then
prepare stmt from 'alter table migtest_fk_none_via_join drop constraint fk_mgtst_fk_9tknzj';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MGTST_FK_WICX8X' and tabname = 'MIGTEST_FK_SET_NULL') then
prepare stmt from 'alter table migtest_fk_set_null drop constraint fk_mgtst_fk_wicx8x';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MGTST__BSC_STTS' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_mgtst__bsc_stts';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MGTST__B_Z543FG' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_mgtst__b_z543fg';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MGTST__B_VS45XO' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_mgtst__b_vs45xo';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MGTST__B_VS45XO') then
prepare stmt from 'drop index uq_mgtst__b_vs45xo';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MGTST__BSC_SR_D' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint fk_mgtst__bsc_sr_d';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MGTST__B_UCFCNE' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_mgtst__b_ucfcne';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MGTST__B_UCFCNE') then
prepare stmt from 'drop index uq_mgtst__b_ucfcne';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MGTST__BSC_NM' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_mgtst__bsc_nm';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MGTST__BSC_NM') then
prepare stmt from 'drop index uq_mgtst__bsc_nm';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MGTST__B_4AYC00' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc00';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MGTST__B_4AYC00') then
prepare stmt from 'drop index uq_mgtst__b_4ayc00';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MGTST__B_4AYC01' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc01';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MGTST__B_4AYC01') then
prepare stmt from 'drop index uq_mgtst__b_4ayc01';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MGTST__N_773SOK' and tabname = 'MIGTEST_E_ENUM') then
prepare stmt from 'alter table migtest_e_enum drop constraint ck_mgtst__n_773sok';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MGTST__B_EU8CSS') then
prepare stmt from 'drop index ix_mgtst__b_eu8css';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MGTST__B_EU8CSV') then
prepare stmt from 'drop index ix_mgtst__b_eu8csv';
execute stmt;
end if;
end$$;
-- apply changes
create table migtest_e_ref (
id integer generated by default as identity not null,
name varchar(127) not null,
constraint pk_migtest_e_ref primary key (id)
);
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;
-- apply alter tables
alter table migtest_e_basic alter column status drop default;
alter table migtest_e_basic alter column status drop not null;
alter table migtest_e_basic alter column status2 set data type varchar(1);
alter table migtest_e_basic alter column status2 set default 'N';
alter table migtest_e_basic alter column status2 set not null;
alter table migtest_e_basic alter column user_id set default 23;
alter table migtest_e_basic alter column user_id set not null;
alter table migtest_e_basic add column description_file blob(64M);
alter table migtest_e_basic add column old_boolean boolean default false not null;
alter table migtest_e_basic add column old_boolean2 boolean;
alter table migtest_e_basic add column eref_id integer;
call sysproc.admin_cmd('reorg table migtest_e_basic');
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'));
alter table migtest_e_basic add constraint ck_mgtst__b_z543fg check ( status2 in ('N','A','I'));
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;
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;
create index ix_mgtst__bsc_rf_d on migtest_e_basic (eref_id);
alter table migtest_e_basic add constraint fk_mgtst__bsc_rf_d foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
create index ix_mgtst__b_eu8csq on migtest_e_basic (indextest1);
create index ix_mgtst__b_eu8csu on migtest_e_basic (indextest5);
@@ -0,0 +1,53 @@
-- 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;
call sysproc.admin_cmd('reorg table migtest_ckey_detail');
alter table migtest_ckey_parent drop column assoc_id;
call sysproc.admin_cmd('reorg table migtest_ckey_parent');
alter table migtest_e_basic drop column new_string_field;
alter table migtest_e_basic drop column new_boolean_field;
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
if exists (select seqschema from syscat.sequences where seqschema = current_schema and seqname = 'MIGTEST_E_USER_SEQ') then
prepare stmt from 'drop sequence migtest_e_user_seq';
execute stmt;
end if;
end$$;
drop table migtest_mtm_c_migtest_mtm_m;
drop table migtest_mtm_m_migtest_mtm_c;
drop table migtest_mtm_m_phone_numbers;
@@ -0,0 +1,7 @@
create or replace view order_agg_vw as
select d.order_id, sum(d.order_qty * d.unit_price) as order_total,
sum(d.ship_qty * d.unit_price) as ship_total
from o_order_detail d
group by d.order_id
@@ -0,0 +1,7 @@
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
@@ -75,9 +75,7 @@ create table migtest_e_basic (
constraint ck_migtest_e_basic_status check ( status in ('N','A','I')),
constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')),
constraint pk_migtest_e_basic primary key (id)
) in TSTABLES index in INDEXTS long in TSTABLES;
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_enum (
id integer generated by default as identity not null,
@@ -130,7 +128,6 @@ create table migtest_e_ref (
name varchar(127) not null,
constraint pk_migtest_e_ref primary key (id)
);
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);
create table migtest_e_softdelete (
id integer generated by default as identity not null,
@@ -162,14 +159,83 @@ create table migtest_oto_master (
constraint pk_migtest_oto_master primary key (id)
);
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
-- 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);
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;
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null;
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict;
create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict;
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
@@ -1,33 +1,5 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
) in TESTTS index in TESTTS long in TESTTS;
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
) in TSMASTER index in TSMASTER long in TSMASTER;
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
) in TSMASTER index in TSMASTER long in TSMASTER;
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict;
alter table migtest_ckey_parent add column assoc_id integer;
-- drop dependencies
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_CASCADE_ONE_ID' and tabname = 'MIGTEST_FK_CASCADE') then
@@ -35,9 +7,6 @@ if exists (select constname from syscat.tabconst where tabschema = current_schem
execute stmt;
end if;
end$$;
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict;
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict;
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_SET_NULL_ONE_ID' and tabname = 'MIGTEST_FK_SET_NULL') then
@@ -45,9 +14,6 @@ if exists (select constname from syscat.tabconst where tabschema = current_schem
execute stmt;
end if;
end$$;
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict;
update migtest_e_basic set status = 'A' where status is null;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS' and tabname = 'MIGTEST_E_BASIC') then
@@ -55,9 +21,6 @@ if exists (select constname from syscat.tabconst where tabschema = current_schem
execute stmt;
end if;
end$$;
alter table migtest_e_basic alter column status set default 'A';
alter table migtest_e_basic alter column status set not null;
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS2' and tabname = 'MIGTEST_E_BASIC') then
@@ -65,28 +28,6 @@ if exists (select constname from syscat.tabconst where tabschema = current_schem
execute stmt;
end if;
end$$;
alter table migtest_e_basic alter column status2 set data type varchar(127);
alter table migtest_e_basic alter column status2 drop default;
alter table migtest_e_basic alter column status2 drop not null;
call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #1 */;
-- db2 does not support parial null indices :( - so we have to clean;
update migtest_e_basic set status = 'N' where id = 1;
create unique index uq_migtest_e_basic_description on migtest_e_basic(description) exclude null keys;
insert into migtest_e_user (id) select distinct user_id from migtest_e_basic;
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict;
alter table migtest_e_basic alter column user_id drop not null;
alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null;
alter table migtest_e_basic add column new_boolean_field boolean default true not null;
call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #2 */;
update migtest_e_basic set new_boolean_field = old_boolean;
alter table migtest_e_basic add column new_boolean_field2 boolean default true not null;
alter table migtest_e_basic add column progress integer default 0 not null;
alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2));
alter table migtest_e_basic add column new_integer integer default 42 not null;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_INDEXTEST2' and tabname = 'MIGTEST_E_BASIC') then
@@ -115,11 +56,6 @@ if exists (select indname from syscat.indexes where indschema = current_schema a
execute stmt;
end if;
end$$;
create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) exclude null keys;
create unique index uq_migtest_e_basic_name on migtest_e_basic(name) exclude null keys;
create unique index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) exclude null keys;
create unique index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) exclude null keys;
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_E_BASIC','USERSPACE1','USERSPACE1','USERSPACE1','','','','','','MOVE');
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_ENUM_TEST_STATUS' and tabname = 'MIGTEST_E_ENUM') then
@@ -127,39 +63,6 @@ if exists (select constname from syscat.tabconst where tabschema = current_schem
execute stmt;
end if;
end$$;
comment on column migtest_e_history.test_string is 'Column altered to long now';
alter table migtest_e_history alter column test_string set data type bigint;
comment on table migtest_e_history is 'We have history now';
call sysproc.admin_cmd('reorg table migtest_e_history') /* reorg #3 */;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history2 set test_string = 'unknown' where test_string is null;
alter table migtest_e_history2 alter column test_string set default 'unknown';
alter table migtest_e_history2 alter column test_string set not null;
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);
alter table migtest_e_history4 alter column test_number set data type bigint;
alter table migtest_e_history5 add column test_boolean boolean default false not null;
call sysproc.admin_cmd('reorg table migtest_e_history2') /* reorg #4 */;
call sysproc.admin_cmd('reorg table migtest_e_history4') /* reorg #5 */;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
alter table migtest_e_history6 alter column test_number1 set default 42;
alter table migtest_e_history6 alter column test_number1 set not null;
alter table migtest_e_history6 alter column test_number2 drop not null;
alter table migtest_e_softdelete add column deleted boolean default false not null;
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');
alter table migtest_oto_child add column master_id bigint;
call sysproc.admin_cmd('reorg table migtest_e_history6') /* reorg #6 */;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST1') then
@@ -174,23 +77,147 @@ if exists (select indname from syscat.indexes where indschema = current_schema a
execute stmt;
end if;
end$$;
-- apply changes
create table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
update migtest_e_basic set status = 'A' where status is null;
-- db2 does not support parial null indices :( - so we have to clean;
update migtest_e_basic set status = 'N' where id = 1;
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);
alter table migtest_ckey_parent add column assoc_id integer;
alter table migtest_e_basic alter column status set default 'A';
alter table migtest_e_basic alter column status set not null;
alter table migtest_e_basic alter column status2 set data type varchar(127);
alter table migtest_e_basic alter column status2 drop default;
alter table migtest_e_basic alter column status2 drop not null;
alter table migtest_e_basic alter column user_id drop not null;
alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null;
alter table migtest_e_basic add column new_boolean_field boolean default true not null;
alter table migtest_e_basic add column new_boolean_field2 boolean default true not null;
alter table migtest_e_basic add column progress integer default 0 not null;
alter table migtest_e_basic add 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';
alter table migtest_e_history2 alter column test_string set not null;
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
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;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_basic set new_boolean_field = old_boolean;
alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2));
create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) exclude null keys;
create unique index uq_migtest_e_basic_name on migtest_e_basic(name) exclude null keys;
create unique index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) exclude null keys;
create unique index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) exclude null keys;
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;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict;
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict;
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict;
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict;
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict 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 restrict on update restrict;
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -1,17 +1,20 @@
-- 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;
alter table migtest_e_basic drop column old_boolean2;
alter table migtest_e_basic drop column eref_id;
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
@@ -20,5 +23,3 @@ if exists (select seqschema from syscat.sequences where seqschema = current_sche
execute stmt;
end if;
end$$;
call sysproc.admin_cmd('reorg table migtest_e_history2') /* reorg #1 */;
call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #2 */;
@@ -1,12 +1,5 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_ref (
id integer generated by default as identity not null,
name varchar(127) not null,
constraint pk_migtest_e_ref primary key (id)
);
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);
-- drop dependencies
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_CKEY_DETAIL_PARENT' and tabname = 'MIGTEST_CKEY_DETAIL') then
@@ -21,7 +14,6 @@ if exists (select constname from syscat.tabconst where tabschema = current_schem
execute stmt;
end if;
end$$;
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_NONE_ONE_ID' and tabname = 'MIGTEST_FK_NONE') then
@@ -43,7 +35,6 @@ if exists (select constname from syscat.tabconst where tabschema = current_schem
execute stmt;
end if;
end$$;
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS' and tabname = 'MIGTEST_E_BASIC') then
@@ -51,12 +42,6 @@ if exists (select constname from syscat.tabconst where tabschema = current_schem
execute stmt;
end if;
end$$;
alter table migtest_e_basic alter column status drop default;
alter table migtest_e_basic alter column status drop not null;
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I'));
call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #1 */;
update migtest_e_basic set status2 = 'N' where status2 is null;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS2' and tabname = 'MIGTEST_E_BASIC') then
@@ -64,10 +49,6 @@ if exists (select constname from syscat.tabconst where tabschema = current_schem
execute stmt;
end if;
end$$;
alter table migtest_e_basic alter column status2 set data type varchar(1);
alter table migtest_e_basic alter column status2 set default 'N';
alter table migtest_e_basic alter column status2 set not null;
alter table migtest_e_basic add constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I'));
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_DESCRIPTION' and tabname = 'MIGTEST_E_BASIC') then
@@ -82,9 +63,6 @@ if exists (select indname from syscat.indexes where indschema = current_schema a
execute stmt;
end if;
end$$;
call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #2 */;
update migtest_e_basic set user_id = 23 where user_id is null;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_E_BASIC_USER_ID' and tabname = 'MIGTEST_E_BASIC') then
@@ -92,13 +70,6 @@ if exists (select constname from syscat.tabconst where tabschema = current_schem
execute stmt;
end if;
end$$;
alter table migtest_e_basic alter column user_id set default 23;
alter table migtest_e_basic alter column user_id set not null;
alter table migtest_e_basic add column description_file blob(64M);
alter table migtest_e_basic add column old_boolean boolean default false not null;
alter table migtest_e_basic add column old_boolean2 boolean;
alter table migtest_e_basic add column eref_id integer;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_STATUS_INDEXTEST1' and tabname = 'MIGTEST_E_BASIC') then
@@ -155,9 +126,6 @@ if exists (select indname from syscat.indexes where indschema = current_schema a
execute stmt;
end if;
end$$;
call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #3 */;
create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys;
create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) exclude null keys;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_ENUM_TEST_STATUS' and tabname = 'MIGTEST_E_ENUM') then
@@ -165,30 +133,6 @@ if exists (select constname from syscat.tabconst where tabschema = current_schem
execute stmt;
end if;
end$$;
alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I'));
comment on column migtest_e_history.test_string is '';
comment on table migtest_e_history is '';
alter table migtest_e_history2 alter column test_string drop default;
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_history4 alter column test_number set data type integer;
alter table migtest_e_history6 alter column test_number1 drop default;
alter table migtest_e_history6 alter column test_number1 drop not null;
call sysproc.admin_cmd('reorg table migtest_e_history2') /* reorg #4 */;
call sysproc.admin_cmd('reorg table migtest_e_history6') /* reorg #5 */;
call sysproc.admin_cmd('reorg table migtest_e_history4') /* reorg #6 */;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
alter table migtest_e_history6 alter column test_number2 set default 7;
alter table migtest_e_history6 alter column test_number2 set not null;
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_C','USERSPACE1','USERSPACE1','USERSPACE1','','','','','','MOVE');
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_M','USERSPACE1','USERSPACE1','USERSPACE1','','','','','','MOVE');
call sysproc.admin_cmd('reorg table migtest_e_history6') /* reorg #7 */;
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST3') then
@@ -203,6 +147,74 @@ if exists (select indname from syscat.indexes where indschema = current_schema a
execute stmt;
end if;
end$$;
create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict;
-- apply changes
create table migtest_e_ref (
id integer generated by default as identity not null,
name varchar(127) not null,
constraint pk_migtest_e_ref primary key (id)
);
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;
-- apply alter tables
alter table migtest_e_basic alter column status drop default;
alter table migtest_e_basic alter column status drop not null;
alter table migtest_e_basic alter column status2 set data type varchar(1);
alter table migtest_e_basic alter column status2 set default 'N';
alter table migtest_e_basic alter column status2 set not null;
alter table migtest_e_basic alter column user_id set default 23;
alter table migtest_e_basic alter column user_id set not null;
alter table migtest_e_basic add column description_file blob(64M);
alter table migtest_e_basic add column old_boolean boolean default false not null;
alter table migtest_e_basic add column old_boolean2 boolean;
alter table migtest_e_basic add column eref_id integer;
call sysproc.admin_cmd('reorg table migtest_e_basic');
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'));
alter table migtest_e_basic add constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I'));
create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys;
create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) exclude null keys;
alter table migtest_e_enum 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;
create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
@@ -1,33 +1,45 @@
-- 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;
call sysproc.admin_cmd('reorg table migtest_ckey_detail');
alter table migtest_ckey_parent drop column assoc_id;
call sysproc.admin_cmd('reorg table migtest_ckey_parent');
alter table migtest_e_basic drop column new_string_field;
alter table migtest_e_basic drop column new_boolean_field;
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
@@ -39,10 +51,3 @@ end$$;
drop table migtest_mtm_c_migtest_mtm_m;
drop table migtest_mtm_m_migtest_mtm_c;
drop table migtest_mtm_m_phone_numbers;
call sysproc.admin_cmd('reorg table migtest_e_history2') /* reorg #1 */;
call sysproc.admin_cmd('reorg table migtest_e_softdelete') /* reorg #2 */;
call sysproc.admin_cmd('reorg table migtest_oto_child') /* reorg #3 */;
call sysproc.admin_cmd('reorg table migtest_ckey_parent') /* reorg #4 */;
call sysproc.admin_cmd('reorg table migtest_e_history5') /* reorg #5 */;
call sysproc.admin_cmd('reorg table migtest_ckey_detail') /* reorg #6 */;
call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #7 */;
@@ -1,9 +1,7 @@
-1602289007, I__create_tablespaces.sql
-366797192, 1.0__initial.sql
2079409430, 1.1.sql
2051718263, 1.2__dropsFor_1.1.sql
-746953026, 1.3.sql
1293885677, 1.4__dropsFor_1.3.sql
-133543359, R__db2_explain_tables.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
@@ -60,7 +60,7 @@ create table migtest_e_basic (
status2 varchar(1) default 'N' not null,
name varchar(127),
description varchar(127),
description_file blob,
description_file blob(64M),
some_date timestamp,
old_boolean boolean default false not null,
old_boolean2 boolean,
@@ -71,11 +71,9 @@ create table migtest_e_basic (
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
user_id integer default 23 not null,
user_id integer not null,
constraint ck_migtest_e_basic_status check ( status in ('N','A','I')),
constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I')),
constraint uq_migtest_e_basic_indextest2 unique (indextest2),
constraint uq_migtest_e_basic_indextest6 unique (indextest6),
constraint pk_migtest_e_basic primary key (id)
);
@@ -88,7 +86,7 @@ create table migtest_e_enum (
create table migtest_e_history (
id integer generated by default as identity not null,
test_string bigint,
test_string varchar(255),
constraint pk_migtest_e_history primary key (id)
);
@@ -121,14 +119,13 @@ create table migtest_e_history5 (
create table migtest_e_history6 (
id integer generated by default as identity not null,
test_number1 integer,
test_number2 integer default 7 not null,
test_number2 integer not null,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_ref (
id integer generated by default as identity not null,
name varchar(127) not null,
constraint uq_migtest_e_ref_name unique (name),
constraint pk_migtest_e_ref primary key (id)
);
@@ -162,8 +159,75 @@ create table migtest_oto_master (
constraint pk_migtest_oto_master primary key (id)
);
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
-- 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);
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;
@@ -173,61 +237,5 @@ alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id for
create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
alter table migtest_e_history2 add column sys_period_start timestamp default now();
alter table migtest_e_history2 add column sys_period_end timestamp;
create table migtest_e_history2_history(
id integer,
test_string varchar(255),
obsolete_string1 varchar(255),
obsolete_string2 varchar(255),
sys_period_start timestamp,
sys_period_end timestamp
);
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
alter table migtest_e_history3 add column sys_period_start timestamp default now();
alter table migtest_e_history3 add column sys_period_end timestamp;
create table migtest_e_history3_history(
id integer,
test_string varchar(255),
sys_period_start timestamp,
sys_period_end timestamp
);
create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history;
alter table migtest_e_history4 add column sys_period_start timestamp default now();
alter table migtest_e_history4 add column sys_period_end timestamp;
create table migtest_e_history4_history(
id integer,
test_number integer,
sys_period_start timestamp,
sys_period_end timestamp
);
create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history;
alter table migtest_e_history5 add column sys_period_start timestamp default now();
alter table migtest_e_history5 add column sys_period_end timestamp;
create table migtest_e_history5_history(
id integer,
test_number integer,
sys_period_start timestamp,
sys_period_end timestamp
);
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
alter table migtest_e_history6 add column sys_period_start timestamp default now();
alter table migtest_e_history6 add column sys_period_end timestamp;
create table migtest_e_history6_history(
id integer,
test_number1 integer,
test_number2 integer,
sys_period_start timestamp,
sys_period_end timestamp
);
create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history;
create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create trigger migtest_e_history6_history_upd before update,delete on migtest_e_history6 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger";
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
@@ -0,0 +1,223 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_CASCADE_ONE_ID' and tabname = 'MIGTEST_FK_CASCADE') then
prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_SET_NULL_ONE_ID' and tabname = 'MIGTEST_FK_SET_NULL') then
prepare stmt from 'alter table migtest_fk_set_null drop constraint fk_migtest_fk_set_null_one_id';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS2' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_INDEXTEST2' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_INDEXTEST2') then
prepare stmt from 'drop index uq_migtest_e_basic_indextest2';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_INDEXTEST6' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_INDEXTEST6') then
prepare stmt from 'drop index uq_migtest_e_basic_indextest6';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_ENUM_TEST_STATUS' and tabname = 'MIGTEST_E_ENUM') then
prepare stmt from 'alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST1') then
prepare stmt from 'drop index ix_migtest_e_basic_indextest1';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST5') then
prepare stmt from 'drop index ix_migtest_e_basic_indextest5';
execute stmt;
end if;
end$$;
-- apply changes
create table migtest_e_user (
id integer generated by default as identity not null,
constraint pk_migtest_e_user primary key (id)
);
create table migtest_mtm_c_migtest_mtm_m (
migtest_mtm_c_id integer not null,
migtest_mtm_m_id bigint not null,
constraint pk_migtest_mtm_c_migtest_mtm_m primary key (migtest_mtm_c_id,migtest_mtm_m_id)
);
create table migtest_mtm_m_migtest_mtm_c (
migtest_mtm_m_id bigint not null,
migtest_mtm_c_id integer not null,
constraint pk_migtest_mtm_m_migtest_mtm_c primary key (migtest_mtm_m_id,migtest_mtm_c_id)
);
create table migtest_mtm_m_phone_numbers (
migtest_mtm_m_id bigint not null,
value varchar(255) not null
);
update migtest_e_basic set status = 'A' where status is null;
-- db2 does not support parial null indices :( - so we have to clean;
update migtest_e_basic set status = 'N' where id = 1;
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);
alter table migtest_ckey_parent add column assoc_id integer;
alter table migtest_e_basic alter column status set default 'A';
alter table migtest_e_basic alter column status set not null;
alter table migtest_e_basic alter column status2 set data type varchar(127);
alter table migtest_e_basic alter column status2 drop default;
alter table migtest_e_basic alter column status2 drop not null;
alter table migtest_e_basic alter column user_id drop not null;
alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null;
alter table migtest_e_basic add column new_boolean_field boolean default true not null;
alter table migtest_e_basic add column new_boolean_field2 boolean default true not null;
alter table migtest_e_basic add column progress integer default 0 not null;
alter table migtest_e_basic add 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';
alter table migtest_e_history2 alter column test_string set not null;
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
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;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_basic set new_boolean_field = old_boolean;
alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2));
create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) exclude null keys;
create unique index uq_migtest_e_basic_name on migtest_e_basic(name) exclude null keys;
create unique index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) exclude null keys;
create unique index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) exclude null keys;
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;
create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m on migtest_mtm_c_migtest_mtm_m (migtest_mtm_m_id);
alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m on migtest_mtm_m_migtest_mtm_c (migtest_mtm_m_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_m foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c on migtest_mtm_m_migtest_mtm_c (migtest_mtm_c_id);
alter table migtest_mtm_m_migtest_mtm_c add constraint fk_migtest_mtm_m_migtest_mtm_c_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict;
create index ix_migtest_mtm_m_phone_numbers_migtest_mtm_m_id on migtest_mtm_m_phone_numbers (migtest_mtm_m_id);
alter table migtest_mtm_m_phone_numbers add constraint fk_migtest_mtm_m_phone_numbers_migtest_mtm_m_id foreign key (migtest_mtm_m_id) references migtest_mtm_m (id) on delete restrict on update restrict;
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict on update restrict;
create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
alter table migtest_ckey_parent add constraint fk_migtest_ckey_parent_assoc_id foreign key (assoc_id) references migtest_ckey_assoc (id) on delete restrict on update restrict;
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict on update restrict;
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict on update restrict;
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict 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 restrict on update restrict;
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict on update restrict;
alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id foreign key (master_id) references migtest_oto_master (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -0,0 +1,25 @@
-- 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;
alter table migtest_e_basic drop column old_boolean2;
alter table migtest_e_basic drop column eref_id;
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
if exists (select seqschema from syscat.sequences where seqschema = current_schema and seqname = 'MIGTEST_E_REF_SEQ') then
prepare stmt from 'drop sequence migtest_e_ref_seq';
execute stmt;
end if;
end$$;
@@ -0,0 +1,220 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_CKEY_DETAIL_PARENT' and tabname = 'MIGTEST_CKEY_DETAIL') then
prepare stmt from 'alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_CASCADE_ONE_ID' and tabname = 'MIGTEST_FK_CASCADE') then
prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_NONE_ONE_ID' and tabname = 'MIGTEST_FK_NONE') then
prepare stmt from 'alter table migtest_fk_none drop constraint fk_migtest_fk_none_one_id';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_NONE_VIA_JOIN_ONE_ID' and tabname = 'MIGTEST_FK_NONE_VIA_JOIN') then
prepare stmt from 'alter table migtest_fk_none_via_join drop constraint fk_migtest_fk_none_via_join_one_id';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_SET_NULL_ONE_ID' and tabname = 'MIGTEST_FK_SET_NULL') then
prepare stmt from 'alter table migtest_fk_set_null drop constraint fk_migtest_fk_set_null_one_id';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS2' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_DESCRIPTION' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_description';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_DESCRIPTION') then
prepare stmt from 'drop index uq_migtest_e_basic_description';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_E_BASIC_USER_ID' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint fk_migtest_e_basic_user_id';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_STATUS_INDEXTEST1' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_STATUS_INDEXTEST1') then
prepare stmt from 'drop index uq_migtest_e_basic_status_indextest1';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_NAME' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_name';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_NAME') then
prepare stmt from 'drop index uq_migtest_e_basic_name';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_INDEXTEST4' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_INDEXTEST4') then
prepare stmt from 'drop index uq_migtest_e_basic_indextest4';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_INDEXTEST5' and tabname = 'MIGTEST_E_BASIC') then
prepare stmt from 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5';
execute stmt;
end if;
end$$
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'UQ_MIGTEST_E_BASIC_INDEXTEST5') then
prepare stmt from 'drop index uq_migtest_e_basic_indextest5';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_ENUM_TEST_STATUS' and tabname = 'MIGTEST_E_ENUM') then
prepare stmt from 'alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST3') then
prepare stmt from 'drop index ix_migtest_e_basic_indextest3';
execute stmt;
end if;
end$$;
delimiter $$
begin
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST6') then
prepare stmt from 'drop index ix_migtest_e_basic_indextest6';
execute stmt;
end if;
end$$;
-- apply changes
create table migtest_e_ref (
id integer generated by default as identity not null,
name varchar(127) not null,
constraint pk_migtest_e_ref primary key (id)
);
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;
-- apply alter tables
alter table migtest_e_basic alter column status drop default;
alter table migtest_e_basic alter column status drop not null;
alter table migtest_e_basic alter column status2 set data type varchar(1);
alter table migtest_e_basic alter column status2 set default 'N';
alter table migtest_e_basic alter column status2 set not null;
alter table migtest_e_basic alter column user_id set default 23;
alter table migtest_e_basic alter column user_id set not null;
alter table migtest_e_basic add column description_file blob(64M);
alter table migtest_e_basic add column old_boolean boolean default false not null;
alter table migtest_e_basic add column old_boolean2 boolean;
alter table migtest_e_basic add column eref_id integer;
call sysproc.admin_cmd('reorg table migtest_e_basic');
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'));
alter table migtest_e_basic add constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I'));
create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys;
create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) exclude null keys;
alter table migtest_e_enum 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;
create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);

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