mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-14 14:46:25 +00:00
Merge remote-tracking branch 'upstream/master'
# Conflicts: # ebean-bom/pom.xml # ebean-core/src/main/java/io/ebeaninternal/server/persist/BatchedPstmt.java # ebean-ddl-generator/src/main/java/io/ebeaninternal/dbmigration/ddlgeneration/platform/DB2Ddl.java # ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.1.sql # ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/1.3.sql # ebean-ddl-generator/src/test/resources/dbmigration/migrationtest/db2/idx_db2.migrations # ebean-test/src/test/java/org/tests/basic/TestMetaAnnotation.java # ebean-test/src/test/java/org/tests/model/basic/cache/TestCacheViaComplexNaturalKey3.java # tests/test-java16/pom.xml # tests/test-kotlin/pom.xml
This commit is contained in:
commit
090f3cddb8
56 files changed
+593
-597
No files matched your search
+12
-2
@@ -18,6 +18,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class BaseDdlHandlerTest extends BaseTestCase {
|
||||
|
||||
private static boolean useV1Syntax = Boolean.getBoolean("ebean.h2.useV1Syntax");
|
||||
|
||||
private final DatabaseConfig serverConfig = new DatabaseConfig();
|
||||
|
||||
private DdlHandler handler(DatabasePlatform platform) {
|
||||
@@ -107,7 +109,11 @@ public class BaseDdlHandlerTest extends BaseTestCase {
|
||||
|
||||
write = new DdlWrite();
|
||||
h2Handler().generate(write, Helper.getAlterTableAddDbArrayColumnWithLength());
|
||||
assertThat(write.apply().getBuffer()).isEqualTo("alter table foo add column dbarray_ninety varchar array;\n\n");
|
||||
if (useV1Syntax) {
|
||||
assertThat(write.apply().getBuffer()).isEqualTo("alter table foo add column dbarray_ninety array;\n\n");
|
||||
} else {
|
||||
assertThat(write.apply().getBuffer()).isEqualTo("alter table foo add column dbarray_ninety varchar array;\n\n");
|
||||
}
|
||||
|
||||
write = new DdlWrite();
|
||||
sqlserverHandler().generate(write, Helper.getAlterTableAddDbArrayColumnWithLength());
|
||||
@@ -127,7 +133,11 @@ public class BaseDdlHandlerTest extends BaseTestCase {
|
||||
|
||||
write = new DdlWrite();
|
||||
h2Handler().generate(write, Helper.getAlterTableAddDbArrayColumnIntegerWithLength());
|
||||
assertThat(write.apply().getBuffer()).isEqualTo("alter table foo add column dbarray_integer integer array;\n\n");
|
||||
if (useV1Syntax) {
|
||||
assertThat(write.apply().getBuffer()).isEqualTo("alter table foo add column dbarray_integer array;\n\n");
|
||||
} else {
|
||||
assertThat(write.apply().getBuffer()).isEqualTo("alter table foo add column dbarray_integer integer array;\n\n");
|
||||
}
|
||||
|
||||
write = new DdlWrite();
|
||||
sqlserverHandler().generate(write, Helper.getAlterTableAddDbArrayColumnIntegerWithLength());
|
||||
|
||||
+13
-4
@@ -25,6 +25,8 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
public class PlatformDdl_AlterColumnTest {
|
||||
|
||||
private static boolean useV1Syntax = Boolean.getBoolean("ebean.h2.useV1Syntax");
|
||||
|
||||
private final PlatformDdl h2Ddl = PlatformDdlBuilder.create(new H2Platform());
|
||||
private final PlatformDdl pgDdl = PlatformDdlBuilder.create(new PostgresPlatform());
|
||||
private final PlatformDdl mysqlDdl = PlatformDdlBuilder.create(new MySqlPlatform());
|
||||
@@ -57,10 +59,17 @@ public class PlatformDdl_AlterColumnTest {
|
||||
|
||||
@Test
|
||||
public void convertArrayType_h2() {
|
||||
assertThat(h2Ddl.convertArrayType("varchar[](90)")).isEqualTo("varchar array");
|
||||
assertThat(h2Ddl.convertArrayType("integer[](60)")).isEqualTo("integer array");
|
||||
assertThat(h2Ddl.convertArrayType("varchar[]")).isEqualTo("varchar array");
|
||||
assertThat(h2Ddl.convertArrayType("integer[]")).isEqualTo("integer array");
|
||||
if (useV1Syntax) {
|
||||
assertThat(h2Ddl.convertArrayType("varchar[](90)")).isEqualTo("array");
|
||||
assertThat(h2Ddl.convertArrayType("integer[](60)")).isEqualTo("array");
|
||||
assertThat(h2Ddl.convertArrayType("varchar[]")).isEqualTo("array");
|
||||
assertThat(h2Ddl.convertArrayType("integer[]")).isEqualTo("array");
|
||||
} else {
|
||||
assertThat(h2Ddl.convertArrayType("varchar[](90)")).isEqualTo("varchar array");
|
||||
assertThat(h2Ddl.convertArrayType("integer[](60)")).isEqualTo("integer array");
|
||||
assertThat(h2Ddl.convertArrayType("varchar[]")).isEqualTo("varchar array");
|
||||
assertThat(h2Ddl.convertArrayType("integer[]")).isEqualTo("integer array");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+35
-27
@@ -13,14 +13,13 @@ import java.util.List;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class MTableTest {
|
||||
class MTableTest {
|
||||
|
||||
static MTable base() {
|
||||
MTable table = new MTable("tab");
|
||||
table.addColumn(new MColumn("id", "bigint"));
|
||||
table.addColumn(new MColumn("name", "varchar(20)"));
|
||||
table.addColumn(new MColumn("status", "varchar(3)"));
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
@@ -29,7 +28,6 @@ public class MTableTest {
|
||||
table.addColumn(new MColumn("id", "bigint"));
|
||||
table.addColumn(new MColumn("name", "varchar(20)"));
|
||||
table.addColumn(new MColumn("comment", "varchar(1000)"));
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
@@ -55,7 +53,7 @@ public class MTableTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void schema() {
|
||||
void schema() {
|
||||
MTable table = new MTable("tab");
|
||||
assertNull(table.getSchema());
|
||||
|
||||
@@ -65,8 +63,29 @@ public class MTableTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_allHistoryColumns() throws Exception {
|
||||
void addColumnScalar_when_new() {
|
||||
MTable table = new MTable("tab");
|
||||
|
||||
MColumn mColumn = table.addColumnScalar("billing_id", "bigint");
|
||||
assertThat(mColumn).isNotNull();
|
||||
assertThat(mColumn.getName()).isEqualTo("billing_id");
|
||||
assertThat(mColumn.getType()).isEqualTo("bigint");
|
||||
}
|
||||
|
||||
@Test
|
||||
void addColumnScalar_when_existingColumnDefined() {
|
||||
MTable table = new MTable("tab");
|
||||
MColumn col = new MColumn("billing_id", "bigint");
|
||||
col.setForeignKeyName("fk_tab_billing_id");
|
||||
col.setForeignKeyIndex("ix_tab_billing_id");
|
||||
table.addColumn(col);
|
||||
|
||||
MColumn mColumn = table.addColumnScalar("billing_id", "bigint");
|
||||
assertThat(mColumn).isSameAs(col);
|
||||
}
|
||||
|
||||
@Test
|
||||
void test_allHistoryColumns() {
|
||||
MTable base = base();
|
||||
base.registerPendingDropColumn("fullName");
|
||||
base.registerPendingDropColumn("last");
|
||||
@@ -76,16 +95,14 @@ public class MTableTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_dropTable() {
|
||||
|
||||
void test_dropTable() {
|
||||
MTable base = base();
|
||||
DropTable dropTable = base.dropTable();
|
||||
assertThat(dropTable.getName()).isEqualTo(base.getName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_compare_addColumnDropColumn() throws Exception {
|
||||
|
||||
void test_compare_addColumnDropColumn() {
|
||||
ModelDiff diff = new ModelDiff();
|
||||
diff.compareTables(base(), newTable());
|
||||
|
||||
@@ -104,8 +121,7 @@ public class MTableTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_compare_addTwoColumnsToSameTable() throws Exception {
|
||||
|
||||
void test_compare_addTwoColumnsToSameTable() {
|
||||
ModelDiff diff = new ModelDiff();
|
||||
diff.compareTables(base(), newTableAdd2Columns());
|
||||
|
||||
@@ -117,12 +133,10 @@ public class MTableTest {
|
||||
assertThat(addColumn.getColumn()).extracting("type").contains("varchar(1000)", "varchar(2000)");
|
||||
|
||||
assertThat(diff.getDropChanges()).hasSize(0);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_compare_modifyColumn() throws Exception {
|
||||
|
||||
void test_compare_modifyColumn() {
|
||||
ModelDiff diff = new ModelDiff();
|
||||
diff.compareTables(base(), newTableModifiedColumn());
|
||||
|
||||
@@ -138,12 +152,10 @@ public class MTableTest {
|
||||
assertThat(alterColumn.getReferences()).isNull();
|
||||
|
||||
assertThat(diff.getDropChanges()).hasSize(0);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_apply_dropColumn() {
|
||||
|
||||
void test_apply_dropColumn() {
|
||||
MTable base = base();
|
||||
|
||||
DropColumn dropColumn = new DropColumn();
|
||||
@@ -155,7 +167,7 @@ public class MTableTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_apply_dropColumn_doesNotExist() {
|
||||
void test_apply_dropColumn_doesNotExist() {
|
||||
MTable base = base();
|
||||
|
||||
DropColumn dropColumn = new DropColumn();
|
||||
@@ -165,7 +177,7 @@ public class MTableTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_apply_alterColumn_doesNotExist() {
|
||||
void test_apply_alterColumn_doesNotExist() {
|
||||
MTable base = base();
|
||||
|
||||
AlterColumn alterColumn = new AlterColumn();
|
||||
@@ -177,8 +189,7 @@ public class MTableTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_apply_alterColumn_type() {
|
||||
|
||||
void test_apply_alterColumn_type() {
|
||||
MTable base = base();
|
||||
|
||||
AlterColumn alterColumn = new AlterColumn();
|
||||
@@ -191,8 +202,7 @@ public class MTableTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_compare_addAndDropColumn() throws Exception {
|
||||
|
||||
void test_compare_addAndDropColumn() {
|
||||
MTable base = base();
|
||||
MTable newTable = newTable();
|
||||
|
||||
@@ -204,8 +214,7 @@ public class MTableTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_compare_addHistoryToTable() {
|
||||
|
||||
void test_compare_addHistoryToTable() {
|
||||
MTable base = base();
|
||||
MTable withHistory = base();
|
||||
withHistory.setWithHistory(true);
|
||||
@@ -219,8 +228,7 @@ public class MTableTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_compare_removeHistoryFromTable() throws Exception {
|
||||
|
||||
void test_compare_removeHistoryFromTable() {
|
||||
MTable withHistory = base();
|
||||
withHistory.setWithHistory(true);
|
||||
|
||||
|
||||
@@ -20,112 +20,52 @@ create table migtest_mtm_m_migtest_mtm_c (
|
||||
alter table migtest_ckey_detail add column one_key integer;
|
||||
alter table migtest_ckey_detail add column two_key varchar(127);
|
||||
|
||||
alter table migtest_ckey_detail add constraint fk_migtest_ckey_detail_parent foreign key (one_key,two_key) references migtest_ckey_parent (one_key,two_key) on delete restrict;
|
||||
alter table migtest_ckey_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_parent add column assoc_id integer;
|
||||
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_CASCADE_ONE_ID' and tabname = 'MIGTEST_FK_CASCADE') then
|
||||
prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id';
|
||||
execute stmt;
|
||||
end if;
|
||||
end$$;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete restrict;
|
||||
alter table migtest_fk_none add constraint fk_migtest_fk_none_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
alter table migtest_fk_none_via_join add constraint fk_migtest_fk_none_via_join_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_SET_NULL_ONE_ID' and tabname = 'MIGTEST_FK_SET_NULL') then
|
||||
prepare stmt from 'alter table migtest_fk_set_null drop constraint fk_migtest_fk_set_null_one_id';
|
||||
execute stmt;
|
||||
end if;
|
||||
end$$;
|
||||
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l;
|
||||
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_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_via_join add constraint fk_mgtst_fk_9tknzj foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
alter table migtest_fk_set_null drop constraint fk_mgtst_fk_wicx8x;
|
||||
alter table migtest_fk_set_null add constraint fk_mgtst_fk_wicx8x foreign key (one_id) references migtest_fk_one (id) on delete restrict;
|
||||
|
||||
update migtest_e_basic set status = 'A' where status is null;
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS' and tabname = 'MIGTEST_E_BASIC') then
|
||||
prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status';
|
||||
execute stmt;
|
||||
end if;
|
||||
end$$;
|
||||
alter table migtest_e_basic drop constraint ck_mgtst__bsc_stts;
|
||||
alter table migtest_e_basic alter column status set default 'A';
|
||||
alter table migtest_e_basic alter column status set not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS2' and tabname = 'MIGTEST_E_BASIC') then
|
||||
prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2';
|
||||
execute stmt;
|
||||
end if;
|
||||
end$$;
|
||||
alter table migtest_e_basic add constraint ck_mgtst__bsc_stts check ( status in ('N','A','I','?'));
|
||||
alter table migtest_e_basic drop constraint ck_mgtst__b_z543fg;
|
||||
alter table migtest_e_basic alter column status2 set data type varchar(127);
|
||||
alter table migtest_e_basic alter column status2 drop default;
|
||||
alter table migtest_e_basic alter column status2 drop not null;
|
||||
|
||||
call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #1 */;
|
||||
-- db2 does not support parial null indices :( - so we have to clean;
|
||||
update migtest_e_basic set status = 'N' where id = 1;
|
||||
-- rename all collisions;
|
||||
create unique index uq_migtest_e_basic_description on migtest_e_basic(description) exclude null keys;
|
||||
|
||||
insert into migtest_e_user (id) select distinct user_id from migtest_e_basic;
|
||||
alter table migtest_e_basic add constraint fk_migtest_e_basic_user_id foreign key (user_id) references migtest_e_user (id) on delete restrict;
|
||||
alter table migtest_e_basic add constraint fk_mgtst__bsc_sr_d foreign key (user_id) references migtest_e_user (id) on delete restrict;
|
||||
alter table migtest_e_basic alter column user_id drop not null;
|
||||
alter table migtest_e_basic add column new_string_field varchar(255) default 'foo''bar' not null;
|
||||
alter table migtest_e_basic add column new_boolean_field boolean default true not null;
|
||||
call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #2 */;
|
||||
update migtest_e_basic set new_boolean_field = old_boolean;
|
||||
|
||||
alter table migtest_e_basic add column new_boolean_field2 boolean default true not null;
|
||||
alter table migtest_e_basic add column progress integer default 0 not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( progress in (0,1,2));
|
||||
alter table migtest_e_basic add constraint ck_mgtst__b_l39g41 check ( progress in (0,1,2));
|
||||
alter table migtest_e_basic add column new_integer integer default 42 not null;
|
||||
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_INDEXTEST2' and tabname = 'MIGTEST_E_BASIC') then
|
||||
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$$;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4aybzy;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc02;
|
||||
create unique index uq_migtest_e_basic_status_indextest1 on migtest_e_basic(status,indextest1) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_name on migtest_e_basic(name) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest4 on migtest_e_basic(indextest4) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest5 on migtest_e_basic(indextest5) exclude null keys;
|
||||
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$$;
|
||||
alter table migtest_e_enum drop constraint ck_mgtst__n_773sok;
|
||||
comment on column migtest_e_history.test_string is 'Column altered to long now';
|
||||
alter table migtest_e_history alter column test_string set data type bigint;
|
||||
comment on table migtest_e_history is 'We have history now';
|
||||
|
||||
call sysproc.admin_cmd('reorg table migtest_e_history') /* reorg #3 */;
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history2 set test_string = 'unknown' where test_string is null;
|
||||
alter table migtest_e_history2 alter column test_string set default 'unknown';
|
||||
@@ -138,8 +78,6 @@ alter table migtest_e_history4 alter column test_number set data type bigint;
|
||||
alter table migtest_e_history5 add column test_boolean boolean default false not null;
|
||||
|
||||
|
||||
call sysproc.admin_cmd('reorg table migtest_e_history2') /* reorg #4 */;
|
||||
call sysproc.admin_cmd('reorg table migtest_e_history4') /* reorg #5 */;
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
|
||||
alter table migtest_e_history6 alter column test_number1 set default 42;
|
||||
@@ -149,37 +87,24 @@ alter table migtest_e_softdelete add column deleted boolean default false not nu
|
||||
|
||||
alter table migtest_oto_child add column master_id bigint;
|
||||
|
||||
call sysproc.admin_cmd('reorg table migtest_e_history6') /* reorg #6 */;
|
||||
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
|
||||
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST1') then
|
||||
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$$;
|
||||
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;
|
||||
create index ix_mgtst__b_eu8css on migtest_e_basic (indextest3);
|
||||
create index ix_mgtst__b_eu8csv on migtest_e_basic (indextest6);
|
||||
drop index ix_mgtst__b_eu8csq;
|
||||
drop index ix_mgtst__b_eu8csu;
|
||||
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;
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
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;
|
||||
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_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_mgtst_t__csyl38 foreign key (master_id) references migtest_oto_master (id) on delete restrict;
|
||||
|
||||
@@ -5,166 +5,44 @@ create table migtest_e_ref (
|
||||
name varchar(127) not null,
|
||||
constraint pk_migtest_e_ref primary key (id)
|
||||
);
|
||||
alter table migtest_e_ref add constraint uq_migtest_e_ref_name unique (name);
|
||||
alter table migtest_e_ref add constraint uq_mgtst__rf_nm unique (name);
|
||||
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_CKEY_DETAIL_PARENT' and tabname = 'MIGTEST_CKEY_DETAIL') then
|
||||
prepare stmt from 'alter table migtest_ckey_detail drop constraint fk_migtest_ckey_detail_parent';
|
||||
execute stmt;
|
||||
end if;
|
||||
end$$;
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_CASCADE_ONE_ID' and tabname = 'MIGTEST_FK_CASCADE') then
|
||||
prepare stmt from 'alter table migtest_fk_cascade drop constraint fk_migtest_fk_cascade_one_id';
|
||||
execute stmt;
|
||||
end if;
|
||||
end$$;
|
||||
alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade;
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_FK_NONE_ONE_ID' and tabname = 'MIGTEST_FK_NONE') then
|
||||
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$$;
|
||||
alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null;
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS' and tabname = 'MIGTEST_E_BASIC') then
|
||||
prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status';
|
||||
execute stmt;
|
||||
end if;
|
||||
end$$;
|
||||
alter table migtest_ckey_detail drop constraint fk_mgtst_ck_e1qkb5;
|
||||
alter table migtest_fk_cascade drop constraint fk_mgtst_fk_65kf6l;
|
||||
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_none drop constraint fk_mgtst_fk_nn_n_d;
|
||||
alter table migtest_fk_none_via_join drop constraint fk_mgtst_fk_9tknzj;
|
||||
alter table migtest_fk_set_null drop constraint fk_mgtst_fk_wicx8x;
|
||||
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_e_basic drop constraint ck_mgtst__bsc_stts;
|
||||
alter table migtest_e_basic alter column status drop default;
|
||||
alter table migtest_e_basic alter column status drop not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I'));
|
||||
alter table migtest_e_basic add constraint ck_mgtst__bsc_stts check ( status in ('N','A','I'));
|
||||
|
||||
call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #1 */;
|
||||
update migtest_e_basic set status2 = 'N' where status2 is null;
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_BASIC_STATUS2' and tabname = 'MIGTEST_E_BASIC') then
|
||||
prepare stmt from 'alter table migtest_e_basic drop constraint ck_migtest_e_basic_status2';
|
||||
execute stmt;
|
||||
end if;
|
||||
end$$;
|
||||
alter table migtest_e_basic drop constraint ck_mgtst__b_z543fg;
|
||||
alter table migtest_e_basic alter column status2 set data type varchar(1);
|
||||
alter table migtest_e_basic alter column status2 set default 'N';
|
||||
alter table migtest_e_basic alter column status2 set not null;
|
||||
alter table migtest_e_basic add constraint ck_migtest_e_basic_status2 check ( status2 in ('N','A','I'));
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_DESCRIPTION' and tabname = 'MIGTEST_E_BASIC') then
|
||||
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$$;
|
||||
alter table migtest_e_basic add constraint ck_mgtst__b_z543fg check ( status2 in ('N','A','I'));
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_vs45xo;
|
||||
|
||||
call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #2 */;
|
||||
update migtest_e_basic set user_id = 23 where user_id is null;
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'FK_MIGTEST_E_BASIC_USER_ID' and tabname = 'MIGTEST_E_BASIC') then
|
||||
prepare stmt from 'alter table migtest_e_basic drop constraint fk_migtest_e_basic_user_id';
|
||||
execute stmt;
|
||||
end if;
|
||||
end$$;
|
||||
alter table migtest_e_basic drop constraint fk_mgtst__bsc_sr_d;
|
||||
alter table migtest_e_basic alter column user_id set default 23;
|
||||
alter table migtest_e_basic alter column user_id set not null;
|
||||
alter table migtest_e_basic add column old_boolean boolean default false not null;
|
||||
alter table migtest_e_basic add column old_boolean2 boolean;
|
||||
alter table migtest_e_basic add column eref_id integer;
|
||||
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'UQ_MIGTEST_E_BASIC_STATUS_INDEXTEST1' and tabname = 'MIGTEST_E_BASIC') then
|
||||
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$$;
|
||||
call sysproc.admin_cmd('reorg table migtest_e_basic') /* reorg #3 */;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_ucfcne;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__bsc_nm;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc00;
|
||||
alter table migtest_e_basic drop constraint uq_mgtst__b_4ayc01;
|
||||
create unique index uq_migtest_e_basic_indextest2 on migtest_e_basic(indextest2) exclude null keys;
|
||||
create unique index uq_migtest_e_basic_indextest6 on migtest_e_basic(indextest6) exclude null keys;
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select constname from syscat.tabconst where tabschema = current_schema and constname = 'CK_MIGTEST_E_ENUM_TEST_STATUS' and tabname = 'MIGTEST_E_ENUM') then
|
||||
prepare stmt from 'alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status';
|
||||
execute stmt;
|
||||
end if;
|
||||
end$$;
|
||||
alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I'));
|
||||
alter table migtest_e_enum drop constraint ck_mgtst__n_773sok;
|
||||
alter table migtest_e_enum add constraint ck_mgtst__n_773sok check ( test_status in ('N','A','I'));
|
||||
comment on column migtest_e_history.test_string is '';
|
||||
comment on table migtest_e_history is '';
|
||||
alter table migtest_e_history2 alter column test_string drop default;
|
||||
@@ -176,30 +54,14 @@ alter table migtest_e_history4 alter column test_number set data type integer;
|
||||
alter table migtest_e_history6 alter column test_number1 drop default;
|
||||
alter table migtest_e_history6 alter column test_number1 drop not null;
|
||||
|
||||
call sysproc.admin_cmd('reorg table migtest_e_history2') /* reorg #4 */;
|
||||
call sysproc.admin_cmd('reorg table migtest_e_history6') /* reorg #5 */;
|
||||
call sysproc.admin_cmd('reorg table migtest_e_history4') /* reorg #6 */;
|
||||
-- NOTE: table has @History - special migration may be necessary
|
||||
update migtest_e_history6 set test_number2 = 7 where test_number2 is null;
|
||||
alter table migtest_e_history6 alter column test_number2 set default 7;
|
||||
alter table migtest_e_history6 alter column test_number2 set not null;
|
||||
call sysproc.admin_cmd('reorg table migtest_e_history6') /* reorg #7 */;
|
||||
create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1);
|
||||
create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5);
|
||||
delimiter $$
|
||||
begin
|
||||
if exists (select indname from syscat.indexes where indschema = current_schema and indname = 'IX_MIGTEST_E_BASIC_INDEXTEST3') then
|
||||
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$$;
|
||||
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;
|
||||
create index ix_mgtst__b_eu8csq on migtest_e_basic (indextest1);
|
||||
create index ix_mgtst__b_eu8csu on migtest_e_basic (indextest5);
|
||||
drop index ix_mgtst__b_eu8css;
|
||||
drop index ix_mgtst__b_eu8csv;
|
||||
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;
|
||||
|
||||
Reference in new issue
Block a user