DB2: Migration is working now

This commit is contained in:
Roland Praml committed 2022-03-14 16:31:34 +01:00
1 parent 4d62958645
commit 05a1b0d64e
25 files changed
+1244 -219

No files matched your search

@@ -1,7 +1,11 @@
package io.ebeaninternal.dbmigration.ddlgeneration.platform; package io.ebeaninternal.dbmigration.ddlgeneration.platform;
import io.ebean.annotation.ConstraintMode; import java.util.ArrayList;
import java.util.List;
import io.ebean.config.dbplatform.DatabasePlatform; import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebeaninternal.dbmigration.ddlgeneration.DdlAlterTable;
import io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite;
/** /**
* DB2 platform specific DDL. * DB2 platform specific DDL.
@@ -12,8 +16,8 @@ public class DB2Ddl extends PlatformDdl {
super(platform); super(platform);
this.dropTableIfExists = "drop table "; this.dropTableIfExists = "drop table ";
this.dropSequenceIfExists = "drop sequence "; this.dropSequenceIfExists = "drop sequence ";
this.dropConstraintIfExists = "drop constraint"; this.dropConstraintIfExists = "NOT USED";
this.dropIndexIfExists = "drop index "; this.dropIndexIfExists = "NOT USED";
this.identitySuffix = " generated by default as identity"; this.identitySuffix = " generated by default as identity";
this.columnSetNull = "drop not null"; this.columnSetNull = "drop not null";
this.columnSetType = "set data type "; this.columnSetType = "set data type ";
@@ -30,7 +34,7 @@ public class DB2Ddl extends PlatformDdl {
throw new NullPointerException(); throw new NullPointerException();
} }
StringBuilder sb = new StringBuilder("create unique index "); StringBuilder sb = new StringBuilder("create unique index ");
sb.append(uqName).append(" on ").append(tableName).append('('); sb.append(maxConstraintName(uqName)).append(" on ").append(tableName).append('(');
for (int i = 0; i < columns.length; i++) { for (int i = 0; i < columns.length; i++) {
if (i > 0) { if (i > 0) {
@@ -43,8 +47,117 @@ public class DB2Ddl extends PlatformDdl {
} }
@Override @Override
protected void appendForeignKeyOnUpdate(StringBuilder buffer, ConstraintMode mode) { public String alterTableDropForeignKey(String tableName, String fkName) {
// do nothing, no on update clause for db2 return alterTableDropConstraint(tableName, fkName);
};
@Override
public String alterTableDropUniqueConstraint(String tableName, String uniqueConstraintName) {
return alterTableDropConstraint(tableName, uniqueConstraintName)
+ "\n" + dropIndex(uniqueConstraintName, tableName);
} }
@Override
public String alterTableDropConstraint(String tableName, String constraintName) {
StringBuilder sb = new StringBuilder(300);
sb.append("delimiter $$\n")
.append("begin\n")
.append("if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = '")
.append(maxConstraintName(constraintName).toUpperCase())
.append("' and tabname = '").append(lowerTableName(tableName).toUpperCase()).append("') then\n")
.append(" prepare stmt from 'alter table ").append(lowerTableName(tableName))
.append(" drop constraint ").append(maxConstraintName(constraintName)).append("';\n")
.append(" execute stmt;\n")
.append("end if;\n")
.append("end$$");
return sb.toString();
}
@Override
public String dropIndex(String indexName, String tableName, boolean concurrent) {
StringBuilder sb = new StringBuilder(300);
sb.append("delimiter $$\n")
.append("begin\n")
.append("if exists (select indname from syscat.indexes where indschema = current_schema and indname = '")
.append(maxConstraintName(indexName).toUpperCase()).append("') then\n")
.append(" prepare stmt from 'drop index ").append(maxConstraintName(indexName)).append("';\n")
.append(" execute stmt;\n")
.append("end if;\n")
.append("end$$");
return sb.toString();
}
@Override
public String dropSequence(String sequenceName) {
StringBuilder sb = new StringBuilder(300);
sb.append("delimiter $$\n");
sb.append("begin\n");
sb.append("if exists (select seqschema from syscat.sequences where seqschema = current_schema and seqname = '")
.append(maxConstraintName(sequenceName).toUpperCase()).append("') then\n");
sb.append(" prepare stmt from 'drop sequence ").append(maxConstraintName(sequenceName)).append("';\n");
sb.append(" execute stmt;\n");
sb.append("end if;\n");
sb.append("end$$");
return sb.toString();
}
@Override
protected DdlAlterTable alterTable(DdlWrite writer, String tableName) {
return writer.applyAlterTable(tableName, Db2AlterTableWrite::new);
};
static class Db2AlterTableWrite extends BaseAlterTableWrite {
public Db2AlterTableWrite(String tableName) {
super(tableName);
}
@Override
protected List<AlterCmd> postProcessCommands(List<AlterCmd> cmds) {
List<AlterCmd> ret = new ArrayList<>(cmds.size() + 1);
boolean requiresReorg = false;
for (AlterCmd cmd : cmds) {
ret.add(cmd);
if (!requiresReorg && checkReorg(cmd)) {
requiresReorg = true;
}
}
if (requiresReorg) {
ret.add(newRawCommand("call sysproc.admin_cmd('reorg table " + tableName() + "')"));
}
return ret;
}
/**
* determine, if we need a reorg.
*
* See: https://www.ibm.com/docs/en/db2/11.5?topic=statements-alter-table The following is the full list of REORG-recommended
* ALTER statements that cause a version change and place the table into a REORG-pending state:
* <ul>
* <li>DROP COLUMN
* <li>ALTER COLUMN SET NOT NULL
* <li>ALTER COLUMN DROP NOT NULL
* <li>ALTER COLUMN SET DATA TYPE, except in the following situations:<br>
* Increasing the length of a VARCHAR or VARGRAPHIC column<br>
* Decreasing the length of a VARCHAR or VARGRAPHIC column without truncating trailing blanks from existing data, when no indexes
* exist on the column
* </ul>
*
*/
private boolean checkReorg(AlterCmd cmd) {
switch (cmd.getOperation()) {
case "drop column":
return true;
case "alter column":
String alter = cmd.getAlternation();
return alter.equals("set not null")
|| alter.equals("drop not default")
|| alter.startsWith("set data type"); // note: altering varchar length only is not detected here
default:
return false;
}
}
}
} }
@@ -165,13 +165,13 @@ create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6)
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name); alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);
-- foreign keys and indices -- foreign keys and indices
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_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) 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); 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); 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_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
@@ -1,14 +1,82 @@
-- Migrationscripts for ebean unittest -- Migrationscripts for ebean unittest
-- drop dependencies -- drop dependencies
alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id; delimiter $$
alter table migtest_fk_set_null drop constraint fk_migtest_fk_set_null_one_id; begin
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status; 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
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2; prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id';
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; execute stmt;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; end if;
alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status; end$$;
drop index ix_migtest_e_basic_indextest1; delimiter $$
drop index ix_migtest_e_basic_indextest5; 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 -- apply changes
create table migtest_e_user ( create table migtest_e_user (
id integer generated by default as identity not null, id integer generated by default as identity not null,
@@ -60,17 +128,22 @@ alter table migtest_e_basic add column new_boolean_field smallint default 0 defa
alter table migtest_e_basic add column new_boolean_field2 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 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 add column new_integer integer default 42 not null;
call sysproc.admin_cmd('reorg table migtest_e_basic');
alter table migtest_e_history alter column test_string set data type bigint; 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 default 'unknown';
alter table migtest_e_history2 alter column test_string set not null; 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_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 test_string3 varchar(255) default 'unknown' not null;
alter table migtest_e_history2 add column new_column varchar(20); alter table migtest_e_history2 add column new_column varchar(20);
call sysproc.admin_cmd('reorg table migtest_e_history2');
alter table migtest_e_history4 alter column test_number set data type bigint; 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_history5 add column test_boolean smallint default 0 default false not null; alter table migtest_e_history5 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 default 42;
alter table migtest_e_history6 alter column test_number1 set not null; 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_history6 alter column test_number2 drop not null;
call sysproc.admin_cmd('reorg table migtest_e_history6');
alter table migtest_e_softdelete add column deleted smallint default 0 default false not null; alter table migtest_e_softdelete add column deleted smallint default 0 default false not null;
alter table migtest_oto_child add column master_id bigint; alter table migtest_oto_child add column master_id bigint;
-- apply post alter -- apply post alter
@@ -88,30 +161,30 @@ 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'; comment on table migtest_e_history is 'We have history now';
-- foreign keys and indices -- 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); 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); 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); 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); 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); 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; 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); 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_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_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; 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; 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; 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; 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; 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_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6); create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -4,8 +4,16 @@ 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_boolean;
alter table migtest_e_basic drop column old_boolean2; alter table migtest_e_basic drop column old_boolean2;
alter table migtest_e_basic drop column eref_id; 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_string1;
alter table migtest_e_history2 drop column obsolete_string2; alter table migtest_e_history2 drop column obsolete_string2;
call sysproc.admin_cmd('reorg table migtest_e_history2');
-- apply post alter -- apply post alter
drop table migtest_e_ref; drop table migtest_e_ref;
drop sequence migtest_e_ref_seq; 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$$;
@@ -1,21 +1,152 @@
-- Migrationscripts for ebean unittest -- Migrationscripts for ebean unittest
-- drop dependencies -- drop dependencies
alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent; delimiter $$
alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id; begin
alter table migtest_fk_none drop constraint fk_migtest_fk_none_one_id; if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_CKEY_DETAIL_PARENT' and tabname = 'MIGTEST_CKEY_DETAIL') then
alter table migtest_fk_none_via_join drop constraint fk_migtest_fk_none_via_join_one_id; prepare stmt from 'alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent';
alter table migtest_fk_set_null drop constraint fk_migtest_fk_set_null_one_id; execute stmt;
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status; end if;
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2; end$$;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_description; delimiter $$
alter table migtest_e_basic drop constraint fk_migtest_e_basic_user_id; begin
alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1; 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
alter table migtest_e_basic drop constraint uq_migtest_e_basic_name; prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id';
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4; execute stmt;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; end if;
alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status; end$$;
drop index ix_migtest_e_basic_indextest3; delimiter $$
drop index ix_migtest_e_basic_indextest6; 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 -- apply changes
create table migtest_e_ref ( create table migtest_e_ref (
id integer generated by default as identity not null, id integer generated by default as identity not null,
@@ -42,15 +173,18 @@ 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_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 old_boolean2 smallint default 0;
alter table migtest_e_basic add column eref_id integer; 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 default;
alter table migtest_e_history2 alter column test_string drop not null; 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_string1 varchar(255);
alter table migtest_e_history2 add column obsolete_string2 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_history4 alter column test_number set data type integer;
call sysproc.admin_cmd('reorg table migtest_e_history4');
alter table migtest_e_history6 alter column test_number1 drop default; 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_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 default 7;
alter table migtest_e_history6 alter column test_number2 set not null; alter table migtest_e_history6 alter column test_number2 set not null;
call sysproc.admin_cmd('reorg table migtest_e_history6');
-- apply post alter -- apply post alter
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name); 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_status check ( status in ('N','A','I'));
@@ -61,10 +195,10 @@ alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check (
comment on column migtest_e_history.test_string is ''; comment on column migtest_e_history.test_string is '';
comment on table migtest_e_history is ''; comment on table migtest_e_history is '';
-- foreign keys and indices -- 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; 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; 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); 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_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
@@ -2,21 +2,34 @@
-- apply alter tables -- apply alter tables
alter table migtest_ckey_detail drop column one_key; alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_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; 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_string_field;
alter table migtest_e_basic drop column new_boolean_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 new_boolean_field2;
alter table migtest_e_basic drop column progress; alter table migtest_e_basic drop column progress;
alter table migtest_e_basic drop column new_integer; alter table migtest_e_basic drop column new_integer;
call sysproc.admin_cmd('reorg table migtest_e_basic');
alter table migtest_e_history2 drop column test_string2; 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 test_string3;
alter table migtest_e_history2 drop column new_column; alter table migtest_e_history2 drop column new_column;
call sysproc.admin_cmd('reorg table migtest_e_history2');
alter table migtest_e_history5 drop column test_boolean; alter table migtest_e_history5 drop column test_boolean;
call sysproc.admin_cmd('reorg table migtest_e_history5');
alter table migtest_e_softdelete drop column deleted; 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; alter table migtest_oto_child drop column master_id;
call sysproc.admin_cmd('reorg table migtest_oto_child');
-- apply post alter -- apply post alter
drop table migtest_e_user; drop table migtest_e_user;
drop sequence migtest_e_user_seq; 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_c_migtest_mtm_m;
drop table migtest_mtm_m_migtest_mtm_c; drop table migtest_mtm_m_migtest_mtm_c;
drop table migtest_mtm_m_phone_numbers; drop table migtest_mtm_m_phone_numbers;
@@ -1,7 +1,7 @@
101990988, 1.0__initial.sql 1004346570, 1.0__initial.sql
1882152352, 1.1.sql 972719393, 1.1.sql
-2081356955, 1.2__dropsFor_1.1.sql 859277843, 1.2__dropsFor_1.1.sql
-1397487290, 1.3.sql -583344310, 1.3.sql
-1610622815, 1.4__dropsFor_1.3.sql 1763447809, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql 561281075, R__order_views.sql
@@ -160,18 +160,18 @@ create table migtest_oto_master (
); );
-- apply post alter -- apply post alter
create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys; create unique index uq_mgtst__b_4aybzy 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 unique index uq_mgtst__b_4ayc02 on migtest_e_basic(indextest6) exclude null keys;
alter table migtest_e_ref add constraint uq_mgtst__rf_nm unique (name); alter table migtest_e_ref add constraint uq_mgtst__rf_nm unique (name);
-- foreign keys and indices -- foreign keys and indices
create index ix_mgtst_fk_mok1xj on migtest_fk_cascade (one_id); 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; 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); 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; 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); 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; 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_eu8csq on migtest_e_basic (indextest1);
create index ix_mgtst__b_eu8csu on migtest_e_basic (indextest5); create index ix_mgtst__b_eu8csu on migtest_e_basic (indextest5);
@@ -1,14 +1,82 @@
-- Migrationscripts for ebean unittest -- Migrationscripts for ebean unittest
-- drop dependencies -- drop dependencies
alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l; delimiter $$
alter table migtest_fk_set_null drop constraint fk_mgtst_fk_wicx8x; begin
alter table migtest_e_basic drop constraint ck_mgtst__bsc_stts; if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MGTST_FK_65KF6L' and tabname = 'MIGTEST_FK_CASCADE') then
alter table migtest_e_basic drop constraint ck_mgtst__b_z543fg; prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l';
alter table migtest_e_basic drop constraint uq_mgtst__b_4aybzy; execute stmt;
alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc02; end if;
alter table migtest_e_enum drop constraint ck_mgtst__n_773sok; end$$;
drop index ix_mgtst__b_eu8csq; delimiter $$
drop index ix_mgtst__b_eu8csu; 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 -- apply changes
create table migtest_e_user ( create table migtest_e_user (
id integer generated by default as identity not null, id integer generated by default as identity not null,
@@ -60,58 +128,63 @@ alter table migtest_e_basic add column new_boolean_field boolean default true no
alter table migtest_e_basic add column new_boolean_field2 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 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 add column new_integer integer default 42 not null;
call sysproc.admin_cmd('reorg table migtest_e_basic');
alter table migtest_e_history alter column test_string set data type bigint; 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 default 'unknown';
alter table migtest_e_history2 alter column test_string set not null; 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_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 test_string3 varchar(255) default 'unknown' not null;
alter table migtest_e_history2 add column new_column varchar(20); alter table migtest_e_history2 add column new_column varchar(20);
call sysproc.admin_cmd('reorg table migtest_e_history2');
alter table migtest_e_history4 alter column test_number set data type bigint; 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_history5 add column test_boolean boolean default false not null; 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 default 42;
alter table migtest_e_history6 alter column test_number1 set not null; 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_history6 alter column test_number2 drop not null;
call sysproc.admin_cmd('reorg table migtest_e_history6');
alter table migtest_e_softdelete add column deleted boolean default false not null; alter table migtest_e_softdelete add column deleted boolean default false not null;
alter table migtest_oto_child add column master_id bigint; alter table migtest_oto_child add column master_id bigint;
-- apply post alter -- apply post alter
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__bsc_stts check ( status in ('N','A','I','?'));
create unique index uq_migtest_e_basic_description on migtest_e_basic(description) exclude null keys; create unique index uq_mgtst__b_vs45xo on migtest_e_basic(description) exclude null keys;
-- NOTE: table has @History - special migration may be necessary -- NOTE: table has @History - special migration may be necessary
update migtest_e_basic set new_boolean_field = old_boolean; 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)); alter table migtest_e_basic add constraint ck_mgtst__b_l39g41 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_mgtst__b_ucfcne 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_mgtst__bsc_nm 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_mgtst__b_4ayc00 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 unique index uq_mgtst__b_4ayc01 on migtest_e_basic(indextest5) exclude null keys;
comment on column migtest_e_history.test_string is 'Column altered to long now'; 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'; comment on table migtest_e_history is 'We have history now';
-- foreign keys and indices -- foreign keys and indices
create index ix_mgtst_mt_3ug4ok on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); 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; 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); 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; 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); 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; 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); 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; 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); 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; 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; 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); 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; 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; 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; 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; 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; 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; 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; 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_eu8css on migtest_e_basic (indextest3);
create index ix_mgtst__b_eu8csv on migtest_e_basic (indextest6); create index ix_mgtst__b_eu8csv on migtest_e_basic (indextest6);
@@ -4,8 +4,16 @@ 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_boolean;
alter table migtest_e_basic drop column old_boolean2; alter table migtest_e_basic drop column old_boolean2;
alter table migtest_e_basic drop column eref_id; 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_string1;
alter table migtest_e_history2 drop column obsolete_string2; alter table migtest_e_history2 drop column obsolete_string2;
call sysproc.admin_cmd('reorg table migtest_e_history2');
-- apply post alter -- apply post alter
drop table migtest_e_ref; drop table migtest_e_ref;
drop sequence migtest_e_ref_seq; 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$$;
@@ -1,21 +1,152 @@
-- Migrationscripts for ebean unittest -- Migrationscripts for ebean unittest
-- drop dependencies -- drop dependencies
alter table migtest_ckey_detail drop constraint fk_mgtst_ck_e1qkb5; delimiter $$
alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l; begin
alter table migtest_fk_none drop constraint fk_mgtst_fk_nn_n_d; if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MGTST_CK_E1QKB5' and tabname = 'MIGTEST_CKEY_DETAIL') then
alter table migtest_fk_none_via_join drop constraint fk_mgtst_fk_9tknzj; prepare stmt from 'alter table migtest_ckey_detail drop constraint fk_mgtst_ck_e1qkb5';
alter table migtest_fk_set_null drop constraint fk_mgtst_fk_wicx8x; execute stmt;
alter table migtest_e_basic drop constraint ck_mgtst__bsc_stts; end if;
alter table migtest_e_basic drop constraint ck_mgtst__b_z543fg; end$$;
alter table migtest_e_basic drop constraint uq_mgtst__b_vs45xo; delimiter $$
alter table migtest_e_basic drop constraint fk_mgtst__bsc_sr_d; begin
alter table migtest_e_basic drop constraint uq_mgtst__b_ucfcne; if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MGTST_FK_65KF6L' and tabname = 'MIGTEST_FK_CASCADE') then
alter table migtest_e_basic drop constraint uq_mgtst__bsc_nm; prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l';
alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc00; execute stmt;
alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc01; end if;
alter table migtest_e_enum drop constraint ck_mgtst__n_773sok; end$$;
drop index ix_mgtst__b_eu8css; delimiter $$
drop index ix_mgtst__b_eu8csv; 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 -- apply changes
create table migtest_e_ref ( create table migtest_e_ref (
id integer generated by default as identity not null, id integer generated by default as identity not null,
@@ -42,29 +173,32 @@ 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_boolean boolean default false not null;
alter table migtest_e_basic add column old_boolean2 boolean; alter table migtest_e_basic add column old_boolean2 boolean;
alter table migtest_e_basic add column eref_id integer; 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 default;
alter table migtest_e_history2 alter column test_string drop not null; 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_string1 varchar(255);
alter table migtest_e_history2 add column obsolete_string2 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_history4 alter column test_number set data type integer;
call sysproc.admin_cmd('reorg table migtest_e_history4');
alter table migtest_e_history6 alter column test_number1 drop default; 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_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 default 7;
alter table migtest_e_history6 alter column test_number2 set not null; alter table migtest_e_history6 alter column test_number2 set not null;
call sysproc.admin_cmd('reorg table migtest_e_history6');
-- apply post alter -- apply post alter
alter table migtest_e_ref add constraint uq_mgtst__rf_nm unique (name); 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__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')); alter table migtest_e_basic add constraint ck_mgtst__b_z543fg 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_mgtst__b_4aybzy 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 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')); 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 column migtest_e_history.test_string is '';
comment on table migtest_e_history is ''; comment on table migtest_e_history is '';
-- foreign keys and indices -- 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; 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; 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); 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; 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_eu8csq on migtest_e_basic (indextest1);
create index ix_mgtst__b_eu8csu on migtest_e_basic (indextest5); create index ix_mgtst__b_eu8csu on migtest_e_basic (indextest5);
@@ -2,21 +2,34 @@
-- apply alter tables -- apply alter tables
alter table migtest_ckey_detail drop column one_key; alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_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; 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_string_field;
alter table migtest_e_basic drop column new_boolean_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 new_boolean_field2;
alter table migtest_e_basic drop column progress; alter table migtest_e_basic drop column progress;
alter table migtest_e_basic drop column new_integer; alter table migtest_e_basic drop column new_integer;
call sysproc.admin_cmd('reorg table migtest_e_basic');
alter table migtest_e_history2 drop column test_string2; 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 test_string3;
alter table migtest_e_history2 drop column new_column; alter table migtest_e_history2 drop column new_column;
call sysproc.admin_cmd('reorg table migtest_e_history2');
alter table migtest_e_history5 drop column test_boolean; alter table migtest_e_history5 drop column test_boolean;
call sysproc.admin_cmd('reorg table migtest_e_history5');
alter table migtest_e_softdelete drop column deleted; 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; alter table migtest_oto_child drop column master_id;
call sysproc.admin_cmd('reorg table migtest_oto_child');
-- apply post alter -- apply post alter
drop table migtest_e_user; drop table migtest_e_user;
drop sequence migtest_e_user_seq; 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_c_migtest_mtm_m;
drop table migtest_mtm_m_migtest_mtm_c; drop table migtest_mtm_m_migtest_mtm_c;
drop table migtest_mtm_m_phone_numbers; drop table migtest_mtm_m_phone_numbers;
@@ -1,7 +1,7 @@
1364985791, 1.0__initial.sql -91718719, 1.0__initial.sql
1265418767, 1.1.sql 827855272, 1.1.sql
-2081356955, 1.2__dropsFor_1.1.sql 859277843, 1.2__dropsFor_1.1.sql
-46810481, 1.3.sql 1257741278, 1.3.sql
-1610622815, 1.4__dropsFor_1.3.sql 1763447809, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql 561281075, R__order_views.sql
@@ -165,13 +165,13 @@ create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6)
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name); alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);
-- foreign keys and indices -- foreign keys and indices
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_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) 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); 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); 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_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
@@ -1,14 +1,82 @@
-- Migrationscripts for ebean unittest -- Migrationscripts for ebean unittest
-- drop dependencies -- drop dependencies
alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id; delimiter $$
alter table migtest_fk_set_null drop constraint fk_migtest_fk_set_null_one_id; begin
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status; 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
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2; prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id';
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; execute stmt;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; end if;
alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status; end$$;
drop index ix_migtest_e_basic_indextest1; delimiter $$
drop index ix_migtest_e_basic_indextest5; 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 -- apply changes
create table migtest_e_user ( create table migtest_e_user (
id integer generated by default as identity not null, id integer generated by default as identity not null,
@@ -60,17 +128,22 @@ alter table migtest_e_basic add column new_boolean_field boolean default true no
alter table migtest_e_basic add column new_boolean_field2 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 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 add column new_integer integer default 42 not null;
call sysproc.admin_cmd('reorg table migtest_e_basic');
alter table migtest_e_history alter column test_string set data type bigint; 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 default 'unknown';
alter table migtest_e_history2 alter column test_string set not null; 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_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 test_string3 varchar(255) default 'unknown' not null;
alter table migtest_e_history2 add column new_column varchar(20); alter table migtest_e_history2 add column new_column varchar(20);
call sysproc.admin_cmd('reorg table migtest_e_history2');
alter table migtest_e_history4 alter column test_number set data type bigint; 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_history5 add column test_boolean boolean default false not null; 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 default 42;
alter table migtest_e_history6 alter column test_number1 set not null; 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_history6 alter column test_number2 drop not null;
call sysproc.admin_cmd('reorg table migtest_e_history6');
alter table migtest_e_softdelete add column deleted boolean default false not null; alter table migtest_e_softdelete add column deleted boolean default false not null;
alter table migtest_oto_child add column master_id bigint; alter table migtest_oto_child add column master_id bigint;
-- apply post alter -- apply post alter
@@ -88,30 +161,30 @@ 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'; comment on table migtest_e_history is 'We have history now';
-- foreign keys and indices -- 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); 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); 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); 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); 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); 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; 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); 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_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_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; 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; 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; 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; 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; 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_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6); create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -4,8 +4,16 @@ 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_boolean;
alter table migtest_e_basic drop column old_boolean2; alter table migtest_e_basic drop column old_boolean2;
alter table migtest_e_basic drop column eref_id; 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_string1;
alter table migtest_e_history2 drop column obsolete_string2; alter table migtest_e_history2 drop column obsolete_string2;
call sysproc.admin_cmd('reorg table migtest_e_history2');
-- apply post alter -- apply post alter
drop table migtest_e_ref; drop table migtest_e_ref;
drop sequence migtest_e_ref_seq; 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$$;
@@ -1,21 +1,152 @@
-- Migrationscripts for ebean unittest -- Migrationscripts for ebean unittest
-- drop dependencies -- drop dependencies
alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent; delimiter $$
alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id; begin
alter table migtest_fk_none drop constraint fk_migtest_fk_none_one_id; if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_CKEY_DETAIL_PARENT' and tabname = 'MIGTEST_CKEY_DETAIL') then
alter table migtest_fk_none_via_join drop constraint fk_migtest_fk_none_via_join_one_id; prepare stmt from 'alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent';
alter table migtest_fk_set_null drop constraint fk_migtest_fk_set_null_one_id; execute stmt;
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status; end if;
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2; end$$;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_description; delimiter $$
alter table migtest_e_basic drop constraint fk_migtest_e_basic_user_id; begin
alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1; 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
alter table migtest_e_basic drop constraint uq_migtest_e_basic_name; prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id';
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4; execute stmt;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; end if;
alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status; end$$;
drop index ix_migtest_e_basic_indextest3; delimiter $$
drop index ix_migtest_e_basic_indextest6; 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 -- apply changes
create table migtest_e_ref ( create table migtest_e_ref (
id integer generated by default as identity not null, id integer generated by default as identity not null,
@@ -42,15 +173,18 @@ 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_boolean boolean default false not null;
alter table migtest_e_basic add column old_boolean2 boolean; alter table migtest_e_basic add column old_boolean2 boolean;
alter table migtest_e_basic add column eref_id integer; 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 default;
alter table migtest_e_history2 alter column test_string drop not null; 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_string1 varchar(255);
alter table migtest_e_history2 add column obsolete_string2 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_history4 alter column test_number set data type integer;
call sysproc.admin_cmd('reorg table migtest_e_history4');
alter table migtest_e_history6 alter column test_number1 drop default; 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_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 default 7;
alter table migtest_e_history6 alter column test_number2 set not null; alter table migtest_e_history6 alter column test_number2 set not null;
call sysproc.admin_cmd('reorg table migtest_e_history6');
-- apply post alter -- apply post alter
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name); 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_status check ( status in ('N','A','I'));
@@ -61,10 +195,10 @@ alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check (
comment on column migtest_e_history.test_string is ''; comment on column migtest_e_history.test_string is '';
comment on table migtest_e_history is ''; comment on table migtest_e_history is '';
-- foreign keys and indices -- 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; 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; 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); 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_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
@@ -2,21 +2,34 @@
-- apply alter tables -- apply alter tables
alter table migtest_ckey_detail drop column one_key; alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_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; 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_string_field;
alter table migtest_e_basic drop column new_boolean_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 new_boolean_field2;
alter table migtest_e_basic drop column progress; alter table migtest_e_basic drop column progress;
alter table migtest_e_basic drop column new_integer; alter table migtest_e_basic drop column new_integer;
call sysproc.admin_cmd('reorg table migtest_e_basic');
alter table migtest_e_history2 drop column test_string2; 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 test_string3;
alter table migtest_e_history2 drop column new_column; alter table migtest_e_history2 drop column new_column;
call sysproc.admin_cmd('reorg table migtest_e_history2');
alter table migtest_e_history5 drop column test_boolean; alter table migtest_e_history5 drop column test_boolean;
call sysproc.admin_cmd('reorg table migtest_e_history5');
alter table migtest_e_softdelete drop column deleted; 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; alter table migtest_oto_child drop column master_id;
call sysproc.admin_cmd('reorg table migtest_oto_child');
-- apply post alter -- apply post alter
drop table migtest_e_user; drop table migtest_e_user;
drop sequence migtest_e_user_seq; 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_c_migtest_mtm_m;
drop table migtest_mtm_m_migtest_mtm_c; drop table migtest_mtm_m_migtest_mtm_c;
drop table migtest_mtm_m_phone_numbers; drop table migtest_mtm_m_phone_numbers;
@@ -1,7 +1,7 @@
840828324, 1.0__initial.sql -583456994, 1.0__initial.sql
-1269751430, 1.1.sql -40028187, 1.1.sql
-2081356955, 1.2__dropsFor_1.1.sql 859277843, 1.2__dropsFor_1.1.sql
-998558087, 1.3.sql -1165877856, 1.3.sql
-1610622815, 1.4__dropsFor_1.3.sql 1763447809, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql 561281075, R__order_views.sql
@@ -165,13 +165,13 @@ create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6)
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name); alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);
-- foreign keys and indices -- foreign keys and indices
create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_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) 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); 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); 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_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
@@ -1,14 +1,82 @@
-- Migrationscripts for ebean unittest -- Migrationscripts for ebean unittest
-- drop dependencies -- drop dependencies
alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id; delimiter $$
alter table migtest_fk_set_null drop constraint fk_migtest_fk_set_null_one_id; begin
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status; 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
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2; prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id';
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest2; execute stmt;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; end if;
alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status; end$$;
drop index ix_migtest_e_basic_indextest1; delimiter $$
drop index ix_migtest_e_basic_indextest5; 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 -- apply changes
create table migtest_e_user ( create table migtest_e_user (
id integer generated by default as identity not null, id integer generated by default as identity not null,
@@ -60,17 +128,22 @@ alter table migtest_e_basic add column new_boolean_field boolean default true no
alter table migtest_e_basic add column new_boolean_field2 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 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 add column new_integer integer default 42 not null;
call sysproc.admin_cmd('reorg table migtest_e_basic');
alter table migtest_e_history alter column test_string set data type bigint; 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 default 'unknown';
alter table migtest_e_history2 alter column test_string set not null; 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_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 test_string3 varchar(255) default 'unknown' not null;
alter table migtest_e_history2 add column new_column varchar(20); alter table migtest_e_history2 add column new_column varchar(20);
call sysproc.admin_cmd('reorg table migtest_e_history2');
alter table migtest_e_history4 alter column test_number set data type bigint; 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_history5 add column test_boolean boolean default false not null; 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 default 42;
alter table migtest_e_history6 alter column test_number1 set not null; 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_history6 alter column test_number2 drop not null;
call sysproc.admin_cmd('reorg table migtest_e_history6');
alter table migtest_e_softdelete add column deleted boolean default false not null; alter table migtest_e_softdelete add column deleted boolean default false not null;
alter table migtest_oto_child add column master_id bigint; alter table migtest_oto_child add column master_id bigint;
-- apply post alter -- apply post alter
@@ -88,30 +161,30 @@ 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'; comment on table migtest_e_history is 'We have history now';
-- foreign keys and indices -- 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); 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); 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); 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); 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); 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; 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); 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_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_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; 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; 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; 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; 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; 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_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6); create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
@@ -4,8 +4,16 @@ 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_boolean;
alter table migtest_e_basic drop column old_boolean2; alter table migtest_e_basic drop column old_boolean2;
alter table migtest_e_basic drop column eref_id; 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_string1;
alter table migtest_e_history2 drop column obsolete_string2; alter table migtest_e_history2 drop column obsolete_string2;
call sysproc.admin_cmd('reorg table migtest_e_history2');
-- apply post alter -- apply post alter
drop table migtest_e_ref; drop table migtest_e_ref;
drop sequence migtest_e_ref_seq; 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$$;
@@ -1,21 +1,152 @@
-- Migrationscripts for ebean unittest -- Migrationscripts for ebean unittest
-- drop dependencies -- drop dependencies
alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent; delimiter $$
alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id; begin
alter table migtest_fk_none drop constraint fk_migtest_fk_none_one_id; if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_CKEY_DETAIL_PARENT' and tabname = 'MIGTEST_CKEY_DETAIL') then
alter table migtest_fk_none_via_join drop constraint fk_migtest_fk_none_via_join_one_id; prepare stmt from 'alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent';
alter table migtest_fk_set_null drop constraint fk_migtest_fk_set_null_one_id; execute stmt;
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status; end if;
alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2; end$$;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_description; delimiter $$
alter table migtest_e_basic drop constraint fk_migtest_e_basic_user_id; begin
alter table migtest_e_basic drop constraint uq_migtest_e_basic_status_indextest1; 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
alter table migtest_e_basic drop constraint uq_migtest_e_basic_name; prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id';
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest4; execute stmt;
alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5; end if;
alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status; end$$;
drop index ix_migtest_e_basic_indextest3; delimiter $$
drop index ix_migtest_e_basic_indextest6; 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 -- apply changes
create table migtest_e_ref ( create table migtest_e_ref (
id integer generated by default as identity not null, id integer generated by default as identity not null,
@@ -42,15 +173,18 @@ 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_boolean boolean default false not null;
alter table migtest_e_basic add column old_boolean2 boolean; alter table migtest_e_basic add column old_boolean2 boolean;
alter table migtest_e_basic add column eref_id integer; 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 default;
alter table migtest_e_history2 alter column test_string drop not null; 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_string1 varchar(255);
alter table migtest_e_history2 add column obsolete_string2 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_history4 alter column test_number set data type integer;
call sysproc.admin_cmd('reorg table migtest_e_history4');
alter table migtest_e_history6 alter column test_number1 drop default; 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_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 default 7;
alter table migtest_e_history6 alter column test_number2 set not null; alter table migtest_e_history6 alter column test_number2 set not null;
call sysproc.admin_cmd('reorg table migtest_e_history6');
-- apply post alter -- apply post alter
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name); 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_status check ( status in ('N','A','I'));
@@ -61,10 +195,10 @@ alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check (
comment on column migtest_e_history.test_string is ''; comment on column migtest_e_history.test_string is '';
comment on table migtest_e_history is ''; comment on table migtest_e_history is '';
-- foreign keys and indices -- 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; 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; 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); 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_indextest1 on migtest_e_basic (indextest1);
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
@@ -2,21 +2,34 @@
-- apply alter tables -- apply alter tables
alter table migtest_ckey_detail drop column one_key; alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_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; 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_string_field;
alter table migtest_e_basic drop column new_boolean_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 new_boolean_field2;
alter table migtest_e_basic drop column progress; alter table migtest_e_basic drop column progress;
alter table migtest_e_basic drop column new_integer; alter table migtest_e_basic drop column new_integer;
call sysproc.admin_cmd('reorg table migtest_e_basic');
alter table migtest_e_history2 drop column test_string2; 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 test_string3;
alter table migtest_e_history2 drop column new_column; alter table migtest_e_history2 drop column new_column;
call sysproc.admin_cmd('reorg table migtest_e_history2');
alter table migtest_e_history5 drop column test_boolean; alter table migtest_e_history5 drop column test_boolean;
call sysproc.admin_cmd('reorg table migtest_e_history5');
alter table migtest_e_softdelete drop column deleted; 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; alter table migtest_oto_child drop column master_id;
call sysproc.admin_cmd('reorg table migtest_oto_child');
-- apply post alter -- apply post alter
drop table migtest_e_user; drop table migtest_e_user;
drop sequence migtest_e_user_seq; 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_c_migtest_mtm_m;
drop table migtest_mtm_m_migtest_mtm_c; drop table migtest_mtm_m_migtest_mtm_c;
drop table migtest_mtm_m_phone_numbers; drop table migtest_mtm_m_phone_numbers;
@@ -1,7 +1,7 @@
840828324, 1.0__initial.sql -583456994, 1.0__initial.sql
-1269751430, 1.1.sql -40028187, 1.1.sql
-2081356955, 1.2__dropsFor_1.1.sql 859277843, 1.2__dropsFor_1.1.sql
-998558087, 1.3.sql -1165877856, 1.3.sql
-1610622815, 1.4__dropsFor_1.3.sql 1763447809, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql 561281075, R__order_views.sql