Add SAP HANA support (#1511)

This commit is contained in:
Jonathan Bregler
2018-10-24 21:38:17 +13:00
committed by Rob Bygrave
parent b1410cc660
commit 158ee9a081
79 changed files with 2596 additions and 215 deletions
@@ -0,0 +1,8 @@
create column table foo (
col1 nvarchar(4) generated by default as identity not null,
col2 nvarchar(30) not null,
col3 nvarchar(30) not null,
constraint pk_foo primary key (col1)
);
comment on table foo is 'comment';
@@ -0,0 +1,235 @@
-- 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),
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),
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),
name nvarchar(127),
description nvarchar(127),
some_date timestamp,
old_boolean boolean default false not null,
old_boolean2 boolean,
eref_id integer,
indextest1 nvarchar(127),
indextest2 nvarchar(127),
indextest3 nvarchar(127),
indextest4 nvarchar(127),
indextest5 nvarchar(127),
indextest6 nvarchar(127),
user_id integer not null,
constraint ck_migtest_e_basic_status check ( status 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 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)
);
create column table migtest_e_history (
id integer generated by default as identity not null,
test_string nvarchar(255),
constraint pk_migtest_e_history primary key (id)
);
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),
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 integer,
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,
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 not null,
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),
constraint pk_migtest_e_softdelete 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_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_oto_child (
id integer generated by default as identity not null,
name nvarchar(255),
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)
);
-- 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 cascade;
-- 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 set null;
-- 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;
create column table migtest_e_history2_history (
id integer,
test_string nvarchar(255),
obsolete_string1 nvarchar(255),
obsolete_string2 nvarchar(255),
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 integer,
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,
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,
test_number2 integer not null,
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;
@@ -0,0 +1,176 @@
-- Migrationscripts for ebean unittest
-- apply changes
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_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_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)
);
alter table migtest_ckey_detail add ( one_key integer);
alter table migtest_ckey_detail add ( two_key nvarchar(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 on update restrict;
alter table migtest_ckey_parent add ( assoc_id integer);
alter table migtest_fk_cascade drop constraint fk_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;
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 drop constraint fk_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;
update migtest_e_basic set status = 'A' where status is null;
delimiter $$
do
begin
declare exit handler for sql_error_code 397 begin end;
exec 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status';
end;
$$;
alter table migtest_e_basic alter ( status nvarchar(1) default 'A' not null);
alter table migtest_e_basic alter ( status nvarchar(1) default 'A' not null);
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
-- rename all collisions;
-- cannot create unique index "uq_migtest_e_basic_description" on table "migtest_e_basic" with nullable columns;
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 on update restrict;
alter table migtest_e_basic alter ( user_id integer);
alter table migtest_e_basic add ( new_string_field nvarchar(255) default 'foo''bar' not null);
alter table migtest_e_basic add ( new_boolean_field boolean default true not null);
update migtest_e_basic set new_boolean_field = old_boolean;
alter table migtest_e_basic add ( new_boolean_field2 boolean default true not null);
alter table migtest_e_basic add ( 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 ( new_integer integer default 42 not null);
delimiter $$
do
begin
declare exit handler for sql_error_code 397 begin end;
exec 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2';
end;
$$;
delimiter $$
do
begin
declare exit handler for sql_error_code 397 begin end;
exec 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6';
end;
$$;
-- cannot create unique index "uq_migtest_e_basic_status_indextest1" on table "migtest_e_basic" with nullable columns;
-- cannot create unique index "uq_migtest_e_basic_name" on table "migtest_e_basic" with nullable columns;
-- cannot create unique index "uq_migtest_e_basic_indextest4" on table "migtest_e_basic" with nullable columns;
-- cannot create unique index "uq_migtest_e_basic_indextest5" on table "migtest_e_basic" with nullable columns;
delimiter $$
do
begin
declare exit handler for sql_error_code 397 begin end;
exec 'alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status';
end;
$$;
comment on column migtest_e_history.test_string is 'Column altered to long now';
alter table migtest_e_history alter ( test_string bigint);
comment on table migtest_e_history is 'We have history now';
alter table migtest_e_history2 drop system versioning /* 0 */;
-- 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 ( test_string nvarchar(255) default 'unknown' not null);
alter table migtest_e_history2 alter ( test_string nvarchar(255) default 'unknown' not null);
alter table migtest_e_history2_history alter ( test_string nvarchar(255) default 'unknown' not null);
alter table migtest_e_history2 add system versioning history table migtest_e_history2_history not validated /* 1 */;
alter table migtest_e_history2 drop system versioning /* 2 */;
alter table migtest_e_history2 add ( test_string2 nvarchar(255));
alter table migtest_e_history2 add ( test_string3 nvarchar(255) default 'unknown' not null);
alter table migtest_e_history2 add ( new_column nvarchar(20));
alter table migtest_e_history2_history add ( test_string2 nvarchar(255));
alter table migtest_e_history2_history add ( test_string3 nvarchar(255) default 'unknown');
alter table migtest_e_history2_history add ( new_column nvarchar(20));
alter table migtest_e_history2 add system versioning history table migtest_e_history2_history not validated /* 3 */;
alter table migtest_e_history3 drop system versioning /* 4 */;
alter table migtest_e_history3 add system versioning history table migtest_e_history3_history not validated /* 5 */;
alter table migtest_e_history4 drop system versioning /* 6 */;
alter table migtest_e_history4 alter ( test_number bigint);
alter table migtest_e_history4_history alter ( test_number bigint);
alter table migtest_e_history4 add system versioning history table migtest_e_history4_history not validated /* 7 */;
alter table migtest_e_history5 drop system versioning /* 8 */;
alter table migtest_e_history5 add ( test_boolean boolean default false not null);
alter table migtest_e_history5_history add ( test_boolean boolean default false);
alter table migtest_e_history5 add system versioning history table migtest_e_history5_history not validated /* 9 */;
alter table migtest_e_history6 drop system versioning /* 10 */;
-- 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 ( test_number1 integer default 42 not null);
alter table migtest_e_history6 alter ( test_number1 integer default 42 not null);
alter table migtest_e_history6_history alter ( test_number1 integer default 42 not null);
alter table migtest_e_history6 add system versioning history table migtest_e_history6_history not validated /* 11 */;
alter table migtest_e_history6 drop system versioning /* 12 */;
alter table migtest_e_history6 alter ( test_number2 integer);
alter table migtest_e_history6_history alter ( test_number2 integer);
alter table migtest_e_history6 add system versioning history table migtest_e_history6_history not validated /* 13 */;
alter table migtest_e_softdelete add ( deleted boolean default false not null);
alter table migtest_oto_child add ( master_id bigint);
-- 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;
delimiter $$
do
begin
declare exit handler for sql_error_code 261 begin end;
exec 'drop index ix_migtest_e_basic_indextest1';
end;
$$;
delimiter $$
do
begin
declare exit handler for sql_error_code 261 begin end;
exec 'drop index ix_migtest_e_basic_indextest5';
end;
$$;
-- 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_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;
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 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;
@@ -0,0 +1,19 @@
-- Migrationscripts for ebean unittest
-- apply changes
CALL usp_ebean_drop_column('migtest_e_basic', 'old_boolean');
CALL usp_ebean_drop_column('migtest_e_basic', 'old_boolean2');
CALL usp_ebean_drop_column('migtest_e_basic', 'eref_id');
alter table migtest_e_history2 drop system versioning /* 0 */;
CALL usp_ebean_drop_column('migtest_e_history2', 'obsolete_string1');
CALL usp_ebean_drop_column('migtest_e_history2_history', 'obsolete_string1');
alter table migtest_e_history2 add system versioning history table migtest_e_history2_history not validated /* 1 */;
alter table migtest_e_history2 drop system versioning /* 2 */;
CALL usp_ebean_drop_column('migtest_e_history2', 'obsolete_string2');
CALL usp_ebean_drop_column('migtest_e_history2_history', 'obsolete_string2');
alter table migtest_e_history2 add system versioning history table migtest_e_history2_history not validated /* 3 */;
drop table migtest_e_ref cascade;
@@ -0,0 +1,134 @@
-- Migrationscripts for ebean unittest
-- apply changes
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)
);
alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent;
alter table migtest_fk_cascade drop constraint fk_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 cascade;
alter table migtest_fk_none drop constraint fk_migtest_fk_none_one_id;
alter table migtest_fk_none_via_join drop constraint fk_migtest_fk_none_via_join_one_id;
alter table migtest_fk_set_null drop constraint fk_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 set null;
delimiter $$
do
begin
declare exit handler for sql_error_code 397 begin end;
exec 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status';
end;
$$;
alter table migtest_e_basic alter ( status nvarchar(1) default null);
alter table migtest_e_basic alter ( status nvarchar(1) default null);
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I'));
delimiter $$
do
begin
declare exit handler for sql_error_code 397 begin end;
exec 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_description';
end;
$$;
update migtest_e_basic set user_id = 23 where user_id is null;
alter table migtest_e_basic drop constraint fk_migtest_e_basic_user_id;
alter table migtest_e_basic alter ( user_id integer default 23 not null);
alter table migtest_e_basic alter ( user_id integer default 23 not null);
alter table migtest_e_basic add ( old_boolean boolean default false not null);
alter table migtest_e_basic add ( old_boolean2 boolean);
alter table migtest_e_basic add ( eref_id integer);
delimiter $$
do
begin
declare exit handler for sql_error_code 397 begin end;
exec 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1';
end;
$$;
delimiter $$
do
begin
declare exit handler for sql_error_code 397 begin end;
exec 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_name';
end;
$$;
delimiter $$
do
begin
declare exit handler for sql_error_code 397 begin end;
exec 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4';
end;
$$;
delimiter $$
do
begin
declare exit handler for sql_error_code 397 begin end;
exec 'alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5';
end;
$$;
-- cannot create unique index "uq_migtest_e_basic_indextest2" on table "migtest_e_basic" with nullable columns;
-- cannot create unique index "uq_migtest_e_basic_indextest6" on table "migtest_e_basic" with nullable columns;
delimiter $$
do
begin
declare exit handler for sql_error_code 397 begin end;
exec 'alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status';
end;
$$;
alter table migtest_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 drop system versioning /* 0 */;
alter table migtest_e_history2 alter ( test_string nvarchar(255) default null);
alter table migtest_e_history2 alter ( test_string nvarchar(255) default null);
alter table migtest_e_history2_history alter ( test_string nvarchar(255) default null);
alter table migtest_e_history2 add system versioning history table migtest_e_history2_history not validated /* 1 */;
alter table migtest_e_history2 drop system versioning /* 2 */;
alter table migtest_e_history2 add ( obsolete_string1 nvarchar(255));
alter table migtest_e_history2 add ( obsolete_string2 nvarchar(255));
alter table migtest_e_history2_history add ( obsolete_string1 nvarchar(255));
alter table migtest_e_history2_history add ( obsolete_string2 nvarchar(255));
alter table migtest_e_history2 add system versioning history table migtest_e_history2_history not validated /* 3 */;
alter table migtest_e_history3 drop system versioning /* 4 */;
alter table migtest_e_history3 add system versioning history table migtest_e_history3_history not validated /* 5 */;
alter table migtest_e_history4 drop system versioning /* 6 */;
alter table migtest_e_history4 alter ( test_number decimal );
alter table migtest_e_history4 alter ( test_number integer);
alter table migtest_e_history4_history alter ( test_number decimal );
alter table migtest_e_history4_history alter ( test_number integer);
alter table migtest_e_history4 add system versioning history table migtest_e_history4_history not validated /* 7 */;
alter table migtest_e_history6 drop system versioning /* 8 */;
alter table migtest_e_history6 alter ( test_number1 integer default null);
alter table migtest_e_history6 alter ( test_number1 integer default null);
alter table migtest_e_history6_history alter ( test_number1 integer default null);
alter table migtest_e_history6 add system versioning history table migtest_e_history6_history not validated /* 9 */;
alter table migtest_e_history6 drop system versioning /* 10 */;
-- 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 ( test_number2 integer default 7 not null);
alter table migtest_e_history6 alter ( test_number2 integer default 7 not null);
alter table migtest_e_history6_history alter ( test_number2 integer default 7 not null);
alter table migtest_e_history6 add system versioning history table migtest_e_history6_history not validated /* 11 */;
-- 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;
delimiter $$
do
begin
declare exit handler for sql_error_code 261 begin end;
exec 'drop index ix_migtest_e_basic_indextest3';
end;
$$;
delimiter $$
do
begin
declare exit handler for sql_error_code 261 begin end;
exec 'drop index ix_migtest_e_basic_indextest6';
end;
$$;
-- 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;
@@ -0,0 +1,51 @@
-- Migrationscripts for ebean unittest
-- drop dependencies
alter table migtest_e_history drop system versioning;
alter table migtest_e_history drop period for system_time;
alter table migtest_e_history drop (sys_period_start,sys_period_end);
drop table migtest_e_history_history cascade;
-- apply changes
CALL usp_ebean_drop_column('migtest_ckey_detail', 'one_key');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'two_key');
CALL usp_ebean_drop_column('migtest_ckey_parent', 'assoc_id');
CALL usp_ebean_drop_column('migtest_e_basic', 'new_string_field');
CALL usp_ebean_drop_column('migtest_e_basic', 'new_boolean_field');
CALL usp_ebean_drop_column('migtest_e_basic', 'new_boolean_field2');
CALL usp_ebean_drop_column('migtest_e_basic', 'progress');
CALL usp_ebean_drop_column('migtest_e_basic', 'new_integer');
alter table migtest_e_history2 drop system versioning /* 0 */;
CALL usp_ebean_drop_column('migtest_e_history2', 'test_string2');
CALL usp_ebean_drop_column('migtest_e_history2_history', 'test_string2');
alter table migtest_e_history2 add system versioning history table migtest_e_history2_history not validated /* 1 */;
alter table migtest_e_history2 drop system versioning /* 2 */;
CALL usp_ebean_drop_column('migtest_e_history2', 'test_string3');
CALL usp_ebean_drop_column('migtest_e_history2_history', 'test_string3');
alter table migtest_e_history2 add system versioning history table migtest_e_history2_history not validated /* 3 */;
alter table migtest_e_history2 drop system versioning /* 4 */;
CALL usp_ebean_drop_column('migtest_e_history2', 'new_column');
CALL usp_ebean_drop_column('migtest_e_history2_history', 'new_column');
alter table migtest_e_history2 add system versioning history table migtest_e_history2_history not validated /* 5 */;
alter table migtest_e_history5 drop system versioning /* 6 */;
CALL usp_ebean_drop_column('migtest_e_history5', 'test_boolean');
CALL usp_ebean_drop_column('migtest_e_history5_history', 'test_boolean');
alter table migtest_e_history5 add system versioning history table migtest_e_history5_history not validated /* 7 */;
CALL usp_ebean_drop_column('migtest_e_softdelete', 'deleted');
CALL usp_ebean_drop_column('migtest_oto_child', 'master_id');
drop table migtest_e_user cascade;
drop table migtest_mtm_c_migtest_mtm_m cascade;
drop table migtest_mtm_m_migtest_mtm_c cascade;
@@ -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;
+5
View File
@@ -158,6 +158,11 @@ datasource.db2.password=veryverysecret#1234
datasource.db2.databaseUrl=jdbc:db2://127.0.0.1:50000/SAMPLE
datasource.db2.databaseDriver=com.ibm.db2.jcc.DB2Driver
datasource.hana.username=EBEAN_TEST
datasource.hana.password=Eb3an_test
datasource.hana.databaseUrl=jdbc:sap://hxehost:39013/?databaseName=HXE
datasource.hana.databaseDriver=com.sap.db.jdbc.Driver
# parameters for migration test
datasource.migrationtest.username=SA
datasource.migrationtest.password=SA
+8
View File
@@ -21,6 +21,14 @@
from o_order_detail d
group by d.order_id;
</ddl-script>
<ddl-script name="order views hana" platforms="hana">
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;
</ddl-script>
<ddl-script name="order views sqlite" platforms="sqlite">
drop view if exists order_agg_vw;