Regenerated scripts & tests

This commit is contained in:
Roland Praml committed 2022-02-07 14:07:10 +01:00
1 parent a93e2e05c5
commit cb89b903fd
101 files changed
+315 -5981

No files matched your search

@@ -199,14 +199,16 @@ datasource.hana.url=jdbc:sap://hxehost:39013/?databaseName=HXE
# parameters for migration test
datasource.migrationtest.username=SA
datasource.migrationtest.password=SA
datasource.migrationtest.url=jdbc:h2:mem:migration
datasource.migrationtest.url=jdbc:h2:mem:migration;NON_KEYWORDS=KEY,VALUE
ebean.migrationtest.applyPrefix=V
ebean.migrationtest.ddl.generate=false
ebean.migrationtest.ddl.run=false
ebean.migrationtest.ddl.header=-- Migrationscripts for ebean unittest
ebean.migrationtest.migration.appName=migrationtest
ebean.migrationtest.migration.migrationPath=dbmigration/migrationtest
ebean.migrationtest.migration.migrationPath=migrationtest/dbmigration
ebean.migrationtest.migration.strict=true
dbmigration.platform.mariadb.useMigrationStoredProcedures=true
dbmigration.platform.mysql.useMigrationStoredProcedures=true
# parameters for migration test
datasource.migrationtest-history.username=SA
@@ -217,5 +219,5 @@ ebean.migrationtest-history.ddl.generate=false
ebean.migrationtest-history.ddl.run=false
ebean.migrationtest-history.ddl.header=-- Migrationscripts for ebean unittest DbMigrationDropHistoryTest
ebean.migrationtest-history.migration.appName=migrationtest-history
ebean.migrationtest-history.migration.migrationPath=dbmigration/migrationtest-history
ebean.migrationtest-history.migration.migrationPath=migrationtest-history/dbmigration
ebean.migrationtest-history.migration.strict=true
@@ -0,0 +1,176 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_ckey_assoc (
id integer auto_increment not null,
assoc_one varchar(255),
constraint pk_migtest_ckey_assoc primary key (id)
);
create table migtest_ckey_detail (
id integer auto_increment not null,
something varchar(255),
constraint pk_migtest_ckey_detail primary key (id)
);
create table migtest_ckey_parent (
one_key integer not null,
two_key varchar(127) not null,
name varchar(255),
version integer not null,
constraint pk_migtest_ckey_parent primary key (one_key,two_key)
);
create table migtest_fk_cascade (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_cascade primary key (id)
);
create table migtest_fk_cascade_one (
id bigint auto_increment not null,
constraint pk_migtest_fk_cascade_one primary key (id)
);
create table migtest_fk_none (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_none primary key (id)
);
create table migtest_fk_none_via_join (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_none_via_join primary key (id)
);
create table migtest_fk_one (
id bigint auto_increment not null,
constraint pk_migtest_fk_one primary key (id)
);
create table migtest_fk_set_null (
id bigint auto_increment not null,
one_id bigint,
constraint pk_migtest_fk_set_null primary key (id)
);
create table migtest_e_basic (
id integer auto_increment not null,
status varchar(1),
status2 varchar(1) default 'N' not null,
name varchar(127),
description varchar(127),
some_date datetime(6),
old_boolean tinyint(1) default 0 not null,
old_boolean2 tinyint(1),
eref_id integer,
indextest1 varchar(127),
indextest2 varchar(127),
indextest3 varchar(127),
indextest4 varchar(127),
indextest5 varchar(127),
indextest6 varchar(127),
user_id integer not null,
constraint uq_migtest_e_basic_indextest2 unique (indextest2),
constraint uq_migtest_e_basic_indextest6 unique (indextest6),
constraint pk_migtest_e_basic primary key (id)
);
create table migtest_e_enum (
id integer auto_increment not null,
test_status varchar(1),
constraint pk_migtest_e_enum primary key (id)
);
create table migtest_e_history (
id integer auto_increment not null,
test_string varchar(255),
constraint pk_migtest_e_history primary key (id)
);
create table migtest_e_history2 (
id integer auto_increment not null,
test_string varchar(255),
obsolete_string1 varchar(255),
obsolete_string2 varchar(255),
constraint pk_migtest_e_history2 primary key (id)
);
create table migtest_e_history3 (
id integer auto_increment not null,
test_string varchar(255),
constraint pk_migtest_e_history3 primary key (id)
);
create table migtest_e_history4 (
id integer auto_increment not null,
test_number integer,
constraint pk_migtest_e_history4 primary key (id)
);
create table migtest_e_history5 (
id integer auto_increment not null,
test_number integer,
constraint pk_migtest_e_history5 primary key (id)
);
create table migtest_e_history6 (
id integer auto_increment not null,
test_number1 integer,
test_number2 integer not null,
constraint pk_migtest_e_history6 primary key (id)
);
create table migtest_e_ref (
id integer auto_increment not null,
name varchar(127) not null,
constraint uq_migtest_e_ref_name unique (name),
constraint pk_migtest_e_ref primary key (id)
);
create table migtest_e_softdelete (
id integer auto_increment not null,
test_string varchar(255),
constraint pk_migtest_e_softdelete primary key (id)
);
create table migtest_mtm_c (
id integer auto_increment not null,
name varchar(255),
constraint pk_migtest_mtm_c primary key (id)
);
create table migtest_mtm_m (
id bigint auto_increment not null,
name varchar(255),
constraint pk_migtest_mtm_m primary key (id)
);
create table migtest_oto_child (
id integer auto_increment not null,
name varchar(255),
constraint 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)
);
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_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id);
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict;
create index ix_migtest_fk_set_null_one_id on migtest_fk_set_null (one_id);
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict;
create index ix_migtest_e_basic_eref_id on migtest_e_basic (eref_id);
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
alter table migtest_e_history2 add 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;
@@ -0,0 +1,106 @@
-- Migrationscripts for ebean unittest
-- apply changes
create table migtest_e_user (
id integer auto_increment 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)
);
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 on update restrict;
alter table migtest_ckey_parent add column assoc_id integer;
alter table migtest_fk_cascade drop foreign key 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 foreign key 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;
alter table migtest_e_basic alter status set default 'A';
alter table migtest_e_basic modify status varchar(1) not null;
alter table migtest_e_basic alter status2 drop default;
alter table migtest_e_basic modify status2 varchar(127);
-- rename all collisions;
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
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 modify user_id integer;
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 tinyint(1) default 1 not null;
update migtest_e_basic set new_boolean_field = old_boolean;
alter table migtest_e_basic add column new_boolean_field2 tinyint(1) default 1 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_basic drop index uq_migtest_e_basic_indextest2;
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest6;
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);
alter table migtest_e_history modify test_string bigint;
alter table migtest_e_history comment = 'We have history now';
-- 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 set default 'unknown';
alter table migtest_e_history2 modify test_string varchar(255) 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 modify test_number bigint;
alter table migtest_e_history5 add column test_boolean tinyint(1) default 0 not null;
-- 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 set default 42;
alter table migtest_e_history6 modify test_number1 integer not null;
alter table migtest_e_history6 modify test_number2 integer;
alter table migtest_e_softdelete add column deleted tinyint(1) default 0 not null;
alter table migtest_oto_child add column master_id bigint;
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
drop index ix_migtest_e_basic_indextest1 on migtest_e_basic;
drop index ix_migtest_e_basic_indextest5 on migtest_e_basic;
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_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_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;
alter table migtest_e_history add system versioning;
lock tables migtest_e_history3 write;
unlock tables;
@@ -0,0 +1,14 @@
-- Migrationscripts for ebean unittest
-- apply changes
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;
drop table if exists migtest_e_ref;
drop sequence if exists migtest_e_ref_seq;
@@ -0,0 +1,61 @@
-- Migrationscripts for ebean unittest
-- apply changes
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)
);
alter table migtest_ckey_detail drop foreign key fk_migtest_ckey_detail_parent;
alter table migtest_fk_cascade drop foreign key 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 restrict;
alter table migtest_fk_none drop foreign key fk_migtest_fk_none_one_id;
alter table migtest_fk_none_via_join drop foreign key fk_migtest_fk_none_via_join_one_id;
alter table migtest_fk_set_null drop foreign key 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 restrict;
alter table migtest_e_basic alter status drop default;
alter table migtest_e_basic modify status varchar(1);
update migtest_e_basic set status2 = 'N' where status2 is null;
alter table migtest_e_basic alter status2 set default 'N';
alter table migtest_e_basic modify status2 varchar(1) not null;
alter table migtest_e_basic drop index uq_migtest_e_basic_description;
update migtest_e_basic set user_id = 23 where user_id is null;
alter table migtest_e_basic drop foreign key fk_migtest_e_basic_user_id;
alter table migtest_e_basic alter user_id set default 23;
alter table migtest_e_basic modify user_id integer not null;
alter table migtest_e_basic add column old_boolean tinyint(1) default 0 not null;
alter table migtest_e_basic add column old_boolean2 tinyint(1);
alter table migtest_e_basic add column eref_id integer;
alter table migtest_e_basic drop index uq_migtest_e_basic_status_indextest1;
alter table migtest_e_basic drop index uq_migtest_e_basic_name;
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest4;
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest5;
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_history comment = '';
alter table migtest_e_history2 alter test_string drop default;
alter table migtest_e_history2 modify test_string varchar(255);
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 modify test_number integer;
alter table migtest_e_history6 alter test_number1 drop default;
alter table migtest_e_history6 modify test_number1 integer;
-- 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 set default 7;
alter table migtest_e_history6 modify test_number2 integer not null;
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
drop index ix_migtest_e_basic_indextest3 on migtest_e_basic;
drop index ix_migtest_e_basic_indextest6 on migtest_e_basic;
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;
lock tables migtest_e_history3 write;
unlock tables;
@@ -0,0 +1,35 @@
-- Migrationscripts for ebean unittest
-- apply changes
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;
drop table if exists migtest_e_user;
drop sequence if exists migtest_e_user_seq;
drop table if exists migtest_mtm_c_migtest_mtm_m;
drop table if exists migtest_mtm_m_migtest_mtm_c;
alter table migtest_e_history drop system versioning;
@@ -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 @@
1615386118, 1.0__initial.sql
1747697741, 1.1.sql
-1462014216, 1.2__dropsFor_1.1.sql
-1957738355, 1.3.sql
1081793242, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql
@@ -1,14 +1,14 @@
-- Migrationscripts for ebean unittest
-- apply changes
alter table migtest_e_basic drop column old_boolean;
CALL usp_ebean_drop_column('migtest_e_basic', 'old_boolean');
alter table migtest_e_basic drop column old_boolean2;
CALL usp_ebean_drop_column('migtest_e_basic', 'old_boolean2');
alter table migtest_e_basic drop column eref_id;
CALL usp_ebean_drop_column('migtest_e_basic', 'eref_id');
alter table migtest_e_history2 drop column obsolete_string1;
CALL usp_ebean_drop_column('migtest_e_history2', 'obsolete_string1');
alter table migtest_e_history2 drop column obsolete_string2;
CALL usp_ebean_drop_column('migtest_e_history2', 'obsolete_string2');
drop table if exists migtest_e_ref;
drop sequence if exists migtest_e_ref_seq;
@@ -1,32 +1,32 @@
-- Migrationscripts for ebean unittest
-- apply changes
alter table migtest_ckey_detail drop column one_key;
CALL usp_ebean_drop_column('migtest_ckey_detail', 'one_key');
alter table migtest_ckey_detail drop column two_key;
CALL usp_ebean_drop_column('migtest_ckey_detail', 'two_key');
alter table migtest_ckey_parent drop column assoc_id;
CALL usp_ebean_drop_column('migtest_ckey_parent', 'assoc_id');
alter table migtest_e_basic drop column new_string_field;
CALL usp_ebean_drop_column('migtest_e_basic', 'new_string_field');
alter table migtest_e_basic drop column new_boolean_field;
CALL usp_ebean_drop_column('migtest_e_basic', 'new_boolean_field');
alter table migtest_e_basic drop column new_boolean_field2;
CALL usp_ebean_drop_column('migtest_e_basic', 'new_boolean_field2');
alter table migtest_e_basic drop column progress;
CALL usp_ebean_drop_column('migtest_e_basic', 'progress');
alter table migtest_e_basic drop column new_integer;
CALL usp_ebean_drop_column('migtest_e_basic', 'new_integer');
alter table migtest_e_history2 drop column test_string2;
CALL usp_ebean_drop_column('migtest_e_history2', 'test_string2');
alter table migtest_e_history2 drop column test_string3;
CALL usp_ebean_drop_column('migtest_e_history2', 'test_string3');
alter table migtest_e_history2 drop column new_column;
CALL usp_ebean_drop_column('migtest_e_history2', 'new_column');
alter table migtest_e_history5 drop column test_boolean;
CALL usp_ebean_drop_column('migtest_e_history5', 'test_boolean');
alter table migtest_e_softdelete drop column deleted;
CALL usp_ebean_drop_column('migtest_e_softdelete', 'deleted');
alter table migtest_oto_child drop column master_id;
CALL usp_ebean_drop_column('migtest_oto_child', 'master_id');
drop table if exists migtest_e_user;
drop sequence if exists migtest_e_user_seq;
@@ -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
$$
@@ -1,7 +1,8 @@
1835064798, I__create_procs.sql
1615386118, 1.0__initial.sql
1747697741, 1.1.sql
-1462014216, 1.2__dropsFor_1.1.sql
-116088700, 1.2__dropsFor_1.1.sql
-1957738355, 1.3.sql
1081793242, 1.4__dropsFor_1.3.sql
1065918589, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql
@@ -3,17 +3,17 @@
drop view if exists migtest_e_history2_with_history;
-- apply changes
alter table migtest_e_basic drop column old_boolean;
CALL usp_ebean_drop_column('migtest_e_basic', 'old_boolean');
alter table migtest_e_basic drop column old_boolean2;
CALL usp_ebean_drop_column('migtest_e_basic', 'old_boolean2');
alter table migtest_e_basic drop column eref_id;
CALL usp_ebean_drop_column('migtest_e_basic', 'eref_id');
alter table migtest_e_history2 drop column obsolete_string1;
alter table migtest_e_history2_history drop column obsolete_string1;
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 drop column obsolete_string2;
alter table migtest_e_history2_history drop column obsolete_string2;
CALL usp_ebean_drop_column('migtest_e_history2', 'obsolete_string2');
CALL usp_ebean_drop_column('migtest_e_history2_history', 'obsolete_string2');
drop table if exists migtest_e_ref;
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
@@ -3,45 +3,45 @@
drop trigger migtest_e_history_history_upd;
drop trigger migtest_e_history_history_del;
drop view migtest_e_history_with_history;
alter table migtest_e_history drop column sys_period_start;
alter table migtest_e_history drop column sys_period_end;
CALL usp_ebean_drop_column('migtest_e_history', 'sys_period_start');
CALL usp_ebean_drop_column('migtest_e_history', 'sys_period_end');
drop table migtest_e_history_history;
drop view if exists migtest_e_history2_with_history;
drop view if exists migtest_e_history5_with_history;
-- apply changes
alter table migtest_ckey_detail drop column one_key;
CALL usp_ebean_drop_column('migtest_ckey_detail', 'one_key');
alter table migtest_ckey_detail drop column two_key;
CALL usp_ebean_drop_column('migtest_ckey_detail', 'two_key');
alter table migtest_ckey_parent drop column assoc_id;
CALL usp_ebean_drop_column('migtest_ckey_parent', 'assoc_id');
alter table migtest_e_basic drop column new_string_field;
CALL usp_ebean_drop_column('migtest_e_basic', 'new_string_field');
alter table migtest_e_basic drop column new_boolean_field;
CALL usp_ebean_drop_column('migtest_e_basic', 'new_boolean_field');
alter table migtest_e_basic drop column new_boolean_field2;
CALL usp_ebean_drop_column('migtest_e_basic', 'new_boolean_field2');
alter table migtest_e_basic drop column progress;
CALL usp_ebean_drop_column('migtest_e_basic', 'progress');
alter table migtest_e_basic drop column new_integer;
CALL usp_ebean_drop_column('migtest_e_basic', 'new_integer');
alter table migtest_e_history2 drop column test_string2;
alter table migtest_e_history2_history drop column test_string2;
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 drop column test_string3;
alter table migtest_e_history2_history drop column test_string3;
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 drop column new_column;
alter table migtest_e_history2_history drop column new_column;
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_history5 drop column test_boolean;
alter table migtest_e_history5_history drop column test_boolean;
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_softdelete drop column deleted;
CALL usp_ebean_drop_column('migtest_e_softdelete', 'deleted');
alter table migtest_oto_child drop column master_id;
CALL usp_ebean_drop_column('migtest_oto_child', 'master_id');
drop table if exists migtest_e_user;
drop table if exists migtest_mtm_c_migtest_mtm_m;
@@ -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
$$
@@ -1,7 +1,8 @@
1835064798, I__create_procs.sql
-1087663151, 1.0__initial.sql
880212944, 1.1.sql
1029390755, 1.2__dropsFor_1.1.sql
1922991807, 1.2__dropsFor_1.1.sql
-380371830, 1.3.sql
1085680731, 1.4__dropsFor_1.3.sql
-1139228843, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql