diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql
index f98c28775..228422449 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.0__initial.sql
@@ -126,7 +126,8 @@ create table "table" (
"from" String,
"to" String,
"varchar" String,
- "foreign" String
+ "foreign" String,
+ textfield String
) ENGINE = Log();
create table migtest_mtm_c (
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.1.sql
index 0489ae14d..9849b051c 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.1.sql
@@ -38,7 +38,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
+alter table "table" alter column textfield set null;
alter table "table" add column "select" String;
+alter table "table" add column textfield2 String;
alter table migtest_ckey_detail add column one_key UInt32;
alter table migtest_ckey_detail add column two_key String;
alter table migtest_ckey_parent add column assoc_id UInt32;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.4__dropsFor_1.3.sql
index b4087d6d6..b7d11cb4d 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/1.4__dropsFor_1.3.sql
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations
index c3612c6c2..15a78f72e 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/clickhouse/idx_clickhouse.migrations
@@ -1,6 +1,6 @@
-235371332, 1.0__initial.sql
-74490120, 1.1.sql
+193400547, 1.0__initial.sql
+540706946, 1.1.sql
688811494, 1.2__dropsFor_1.1.sql
1015552567, 1.3.sql
-80209848, 1.4__dropsFor_1.3.sql
+255653518, 1.4__dropsFor_1.3.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.0__initial.sql
index 71fc29b04..4f47e0774 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.0__initial.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.1.sql
index 5c0070d16..183dcdc71 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.1.sql
@@ -46,7 +46,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
+alter table "table" alter column textfield drop not null;
alter table "table" add column "select" varchar(255);
+alter table "table" add column textfield2 varchar(255);
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -116,3 +118,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on "table" (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.3.sql
index 8397edb71..88945c112 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.3.sql
@@ -16,6 +16,7 @@ drop index uq_migtest_e_basic_indextest5 cascade;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
+drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.4__dropsFor_1.3.sql
index 6db145c5c..a643969f8 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/1.4__dropsFor_1.3.sql
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/idx_cockroach.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/idx_cockroach.migrations
index 521df7740..debd08772 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/idx_cockroach.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/cockroach/idx_cockroach.migrations
@@ -1,7 +1,7 @@
--703764770, 1.0__initial.sql
-773862451, 1.1.sql
+1434934404, 1.0__initial.sql
+1284257915, 1.1.sql
856096334, 1.2__dropsFor_1.1.sql
-17665322, 1.3.sql
--820814009, 1.4__dropsFor_1.3.sql
+-1551362011, 1.3.sql
+-971909974, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.0__initial.sql
index 98315d5d8..9931da4b1 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.0__initial.sql
@@ -152,6 +152,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255) not null,
constraint pk_table primary key ("index")
);
comment on column "table"."index" is 'this is a comment';
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.1.sql
index 669dacdf7..3032d4353 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.1.sql
@@ -130,7 +130,10 @@ alter table "table" drop versioning;
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_C','TESTTS','TESTTS','TESTTS','','','','','','MOVE');
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_M','TSMASTER','TSMASTER','TSMASTER','','','','','','MOVE');
-- apply alter tables
+alter table "table" alter column textfield drop not null;
alter table "table" add column "select" varchar(255);
+alter table "table" add column textfield2 varchar(255);
+call sysproc.admin_cmd('reorg table "table"');
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -180,7 +183,10 @@ alter table migtest_e_history6_history alter column test_number2 drop not null;
call sysproc.admin_cmd('reorg table migtest_e_history6_history');
alter table migtest_e_softdelete add column deleted smallint default 0 default false not null;
alter table migtest_oto_child add column master_id bigint;
+alter table table_history alter column textfield drop not null;
alter table table_history add column "select" varchar(255);
+alter table table_history add column textfield2 varchar(255);
+call sysproc.admin_cmd('reorg table table_history');
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
create unique index uq_migtest_e_basic_description on migtest_e_basic(description) exclude null keys;
@@ -232,3 +238,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on "table" (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.3.sql
index 67dc90eff..5baddc80a 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.3.sql
@@ -147,6 +147,13 @@ if exists (select indname from syscat.indexes where indschema = current_schema a
execute stmt;
end if;
end$$;
+delimiter $$
+begin
+if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_TABLE_TEXTFIELD2') then
+ prepare stmt from 'drop index ix_table_textfield2';
+ execute stmt;
+end if;
+end$$;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
@@ -200,9 +207,11 @@ alter table migtest_e_history2 alter column test_string drop default;
alter table migtest_e_history2 alter column test_string drop not null;
alter table migtest_e_history2 add column obsolete_string1 varchar(255);
alter table migtest_e_history2 add column obsolete_string2 varchar(255);
+call sysproc.admin_cmd('reorg table migtest_e_history2');
alter table migtest_e_history2_history alter column test_string drop not null;
alter table migtest_e_history2_history add column obsolete_string1 varchar(255);
alter table migtest_e_history2_history add column obsolete_string2 varchar(255);
+call sysproc.admin_cmd('reorg table migtest_e_history2_history');
alter table migtest_e_history4 alter column test_number set data type integer;
call sysproc.admin_cmd('reorg table migtest_e_history4');
alter table migtest_e_history4_history alter column test_number set data type integer;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.4__dropsFor_1.3.sql
index 95bd2ed00..ecc7c99fa 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/1.4__dropsFor_1.3.sql
@@ -4,7 +4,11 @@ alter table migtest_e_history drop versioning;
alter table migtest_e_history drop period system_time;
alter table migtest_e_history2 drop versioning;
alter table migtest_e_history5 drop versioning;
+alter table "table" drop versioning;
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
+call sysproc.admin_cmd('reorg table "table"');
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
call sysproc.admin_cmd('reorg table migtest_ckey_detail');
@@ -36,10 +40,14 @@ alter table migtest_e_softdelete drop column deleted;
call sysproc.admin_cmd('reorg table migtest_e_softdelete');
alter table migtest_oto_child drop column master_id;
call sysproc.admin_cmd('reorg table migtest_oto_child');
+alter table table_history drop column textfield;
+alter table table_history drop column textfield2;
+call sysproc.admin_cmd('reorg table table_history');
-- apply post alter
drop table migtest_e_history_history;
alter table migtest_e_history2 add versioning use history table migtest_e_history2_history;
alter table migtest_e_history5 add versioning use history table migtest_e_history5_history;
+alter table "table" add versioning use history table table_history;
drop table migtest_e_user;
delimiter $$
begin
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/idx_db2.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/idx_db2.migrations
index 9279653ce..39e65b2d4 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/idx_db2.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2fori/idx_db2.migrations
@@ -1,8 +1,8 @@
-1873955813, 1.0__initial.sql
--1557626294, 1.1.sql
+-1467839063, 1.0__initial.sql
+-184000413, 1.1.sql
-1187336846, 1.2__dropsFor_1.1.sql
-2066110925, 1.3.sql
--1713819679, 1.4__dropsFor_1.3.sql
+-150875853, 1.3.sql
+946163478, 1.4__dropsFor_1.3.sql
-133543359, R__db2_explain_tables.sql
561281075, R__order_views.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.0__initial.sql
index 4deaeeaa5..7b7bddd1d 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.0__initial.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.1.sql
index 7d28dfd4b..645d357f2 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.1.sql
@@ -46,7 +46,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
+alter table "table" alter column textfield set null;
alter table "table" add column "select" varchar(255);
+alter table "table" add column textfield2 varchar(255);
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -119,3 +121,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on "table" (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.3.sql
index ac80b64d5..d41f2877a 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.3.sql
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
+drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.4__dropsFor_1.3.sql
index b4087d6d6..b7d11cb4d 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/1.4__dropsFor_1.3.sql
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_generic.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_generic.migrations
index d016b1917..c9faf50c4 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_generic.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2legacy/idx_generic.migrations
@@ -1,6 +1,6 @@
--710189690, 1.0__initial.sql
--145836847, 1.1.sql
+-1547037623, 1.0__initial.sql
+253988246, 1.1.sql
688811494, 1.2__dropsFor_1.1.sql
-2025934113, 1.3.sql
-80209848, 1.4__dropsFor_1.3.sql
+509168727, 1.3.sql
+255653518, 1.4__dropsFor_1.3.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.0__initial.sql
index 7bd62bcb0..8b9d60aad 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.0__initial.sql
@@ -152,6 +152,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255) not null,
constraint pk_table primary key ("index")
);
comment on column "table"."index" is 'this is a comment';
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.1.sql
index 9c00294bc..2f4beedaa 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.1.sql
@@ -130,7 +130,10 @@ alter table "table" drop versioning;
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_C','TESTTS','TESTTS','TESTTS','','','','','','MOVE');
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_M','TSMASTER','TSMASTER','TSMASTER','','','','','','MOVE');
-- apply alter tables
+alter table "table" alter column textfield drop not null;
alter table "table" add column "select" varchar(255);
+alter table "table" add column textfield2 varchar(255);
+call sysproc.admin_cmd('reorg table "table"');
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -180,7 +183,10 @@ alter table migtest_e_history6_history alter column test_number2 drop not null;
call sysproc.admin_cmd('reorg table migtest_e_history6_history');
alter table migtest_e_softdelete add column deleted boolean default false not null;
alter table migtest_oto_child add column master_id bigint;
+alter table table_history alter column textfield drop not null;
alter table table_history add column "select" varchar(255);
+alter table table_history add column textfield2 varchar(255);
+call sysproc.admin_cmd('reorg table table_history');
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
create unique index uq_migtest_e_basic_description on migtest_e_basic(description) exclude null keys;
@@ -232,3 +238,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on "table" (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.3.sql
index f61a3c695..4a672dd72 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.3.sql
@@ -147,6 +147,13 @@ if exists (select indname from syscat.indexes where indschema = current_schema a
execute stmt;
end if;
end$$;
+delimiter $$
+begin
+if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_TABLE_TEXTFIELD2') then
+ prepare stmt from 'drop index ix_table_textfield2';
+ execute stmt;
+end if;
+end$$;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
@@ -200,9 +207,11 @@ alter table migtest_e_history2 alter column test_string drop default;
alter table migtest_e_history2 alter column test_string drop not null;
alter table migtest_e_history2 add column obsolete_string1 varchar(255);
alter table migtest_e_history2 add column obsolete_string2 varchar(255);
+call sysproc.admin_cmd('reorg table migtest_e_history2');
alter table migtest_e_history2_history alter column test_string drop not null;
alter table migtest_e_history2_history add column obsolete_string1 varchar(255);
alter table migtest_e_history2_history add column obsolete_string2 varchar(255);
+call sysproc.admin_cmd('reorg table migtest_e_history2_history');
alter table migtest_e_history4 alter column test_number set data type integer;
call sysproc.admin_cmd('reorg table migtest_e_history4');
alter table migtest_e_history4_history alter column test_number set data type integer;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.4__dropsFor_1.3.sql
index 95bd2ed00..ecc7c99fa 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/1.4__dropsFor_1.3.sql
@@ -4,7 +4,11 @@ alter table migtest_e_history drop versioning;
alter table migtest_e_history drop period system_time;
alter table migtest_e_history2 drop versioning;
alter table migtest_e_history5 drop versioning;
+alter table "table" drop versioning;
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
+call sysproc.admin_cmd('reorg table "table"');
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
call sysproc.admin_cmd('reorg table migtest_ckey_detail');
@@ -36,10 +40,14 @@ alter table migtest_e_softdelete drop column deleted;
call sysproc.admin_cmd('reorg table migtest_e_softdelete');
alter table migtest_oto_child drop column master_id;
call sysproc.admin_cmd('reorg table migtest_oto_child');
+alter table table_history drop column textfield;
+alter table table_history drop column textfield2;
+call sysproc.admin_cmd('reorg table table_history');
-- apply post alter
drop table migtest_e_history_history;
alter table migtest_e_history2 add versioning use history table migtest_e_history2_history;
alter table migtest_e_history5 add versioning use history table migtest_e_history5_history;
+alter table "table" add versioning use history table table_history;
drop table migtest_e_user;
delimiter $$
begin
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/idx_db2.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/idx_db2.migrations
index 1fa07a37a..a0380e2e7 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/idx_db2.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2luw/idx_db2.migrations
@@ -1,9 +1,9 @@
1307787475, I__create_tablespaces.sql
--1998060342, 1.0__initial.sql
-1595289592, 1.1.sql
+2058232717, 1.0__initial.sql
+-1450326352, 1.1.sql
-1187336846, 1.2__dropsFor_1.1.sql
--1088179698, 1.3.sql
--1713819679, 1.4__dropsFor_1.3.sql
+1976888196, 1.3.sql
+946163478, 1.4__dropsFor_1.3.sql
-133543359, R__db2_explain_tables.sql
561281075, R__order_views.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.0__initial.sql
index 7bd62bcb0..8b9d60aad 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.0__initial.sql
@@ -152,6 +152,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255) not null,
constraint pk_table primary key ("index")
);
comment on column "table"."index" is 'this is a comment';
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.1.sql
index 9c00294bc..2f4beedaa 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.1.sql
@@ -130,7 +130,10 @@ alter table "table" drop versioning;
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_C','TESTTS','TESTTS','TESTTS','','','','','','MOVE');
CALL SYSPROC.ADMIN_MOVE_TABLE(CURRENT_SCHEMA,'MIGTEST_MTM_M','TSMASTER','TSMASTER','TSMASTER','','','','','','MOVE');
-- apply alter tables
+alter table "table" alter column textfield drop not null;
alter table "table" add column "select" varchar(255);
+alter table "table" add column textfield2 varchar(255);
+call sysproc.admin_cmd('reorg table "table"');
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -180,7 +183,10 @@ alter table migtest_e_history6_history alter column test_number2 drop not null;
call sysproc.admin_cmd('reorg table migtest_e_history6_history');
alter table migtest_e_softdelete add column deleted boolean default false not null;
alter table migtest_oto_child add column master_id bigint;
+alter table table_history alter column textfield drop not null;
alter table table_history add column "select" varchar(255);
+alter table table_history add column textfield2 varchar(255);
+call sysproc.admin_cmd('reorg table table_history');
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
create unique index uq_migtest_e_basic_description on migtest_e_basic(description) exclude null keys;
@@ -232,3 +238,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on "table" (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.3.sql
index f61a3c695..4a672dd72 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.3.sql
@@ -147,6 +147,13 @@ if exists (select indname from syscat.indexes where indschema = current_schema a
execute stmt;
end if;
end$$;
+delimiter $$
+begin
+if exists (select indname from syscat.indexes where indschema = current_schema and ucase(indname) = 'IX_TABLE_TEXTFIELD2') then
+ prepare stmt from 'drop index ix_table_textfield2';
+ execute stmt;
+end if;
+end$$;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
@@ -200,9 +207,11 @@ alter table migtest_e_history2 alter column test_string drop default;
alter table migtest_e_history2 alter column test_string drop not null;
alter table migtest_e_history2 add column obsolete_string1 varchar(255);
alter table migtest_e_history2 add column obsolete_string2 varchar(255);
+call sysproc.admin_cmd('reorg table migtest_e_history2');
alter table migtest_e_history2_history alter column test_string drop not null;
alter table migtest_e_history2_history add column obsolete_string1 varchar(255);
alter table migtest_e_history2_history add column obsolete_string2 varchar(255);
+call sysproc.admin_cmd('reorg table migtest_e_history2_history');
alter table migtest_e_history4 alter column test_number set data type integer;
call sysproc.admin_cmd('reorg table migtest_e_history4');
alter table migtest_e_history4_history alter column test_number set data type integer;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.4__dropsFor_1.3.sql
index 95bd2ed00..ecc7c99fa 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/1.4__dropsFor_1.3.sql
@@ -4,7 +4,11 @@ alter table migtest_e_history drop versioning;
alter table migtest_e_history drop period system_time;
alter table migtest_e_history2 drop versioning;
alter table migtest_e_history5 drop versioning;
+alter table "table" drop versioning;
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
+call sysproc.admin_cmd('reorg table "table"');
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
call sysproc.admin_cmd('reorg table migtest_ckey_detail');
@@ -36,10 +40,14 @@ alter table migtest_e_softdelete drop column deleted;
call sysproc.admin_cmd('reorg table migtest_e_softdelete');
alter table migtest_oto_child drop column master_id;
call sysproc.admin_cmd('reorg table migtest_oto_child');
+alter table table_history drop column textfield;
+alter table table_history drop column textfield2;
+call sysproc.admin_cmd('reorg table table_history');
-- apply post alter
drop table migtest_e_history_history;
alter table migtest_e_history2 add versioning use history table migtest_e_history2_history;
alter table migtest_e_history5 add versioning use history table migtest_e_history5_history;
+alter table "table" add versioning use history table table_history;
drop table migtest_e_user;
delimiter $$
begin
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/idx_db2.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/idx_db2.migrations
index c7cd19efb..382351279 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/idx_db2.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/db2zos/idx_db2.migrations
@@ -1,8 +1,8 @@
--1998060342, 1.0__initial.sql
-1595289592, 1.1.sql
+2058232717, 1.0__initial.sql
+-1450326352, 1.1.sql
-1187336846, 1.2__dropsFor_1.1.sql
--1088179698, 1.3.sql
--1713819679, 1.4__dropsFor_1.3.sql
+1976888196, 1.3.sql
+946163478, 1.4__dropsFor_1.3.sql
-133543359, R__db2_explain_tables.sql
561281075, R__order_views.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.0__initial.sql
index 4deaeeaa5..7b7bddd1d 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.0__initial.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.1.sql
index 7d28dfd4b..645d357f2 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.1.sql
@@ -46,7 +46,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
+alter table "table" alter column textfield set null;
alter table "table" add column "select" varchar(255);
+alter table "table" add column textfield2 varchar(255);
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -119,3 +121,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on "table" (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.3.sql
index ac80b64d5..d41f2877a 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.3.sql
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
+drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.4__dropsFor_1.3.sql
index b4087d6d6..b7d11cb4d 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/1.4__dropsFor_1.3.sql
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/idx_generic.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/idx_generic.migrations
index d016b1917..c9faf50c4 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/generic/idx_generic.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/generic/idx_generic.migrations
@@ -1,6 +1,6 @@
--710189690, 1.0__initial.sql
--145836847, 1.1.sql
+-1547037623, 1.0__initial.sql
+253988246, 1.1.sql
688811494, 1.2__dropsFor_1.1.sql
-2025934113, 1.3.sql
-80209848, 1.4__dropsFor_1.3.sql
+509168727, 1.3.sql
+255653518, 1.4__dropsFor_1.3.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.0__initial.sql
index 421988c4d..d405e6e70 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.0__initial.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -254,6 +255,7 @@ create table table_history(
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255),
sys_period_start timestamp,
sys_period_end timestamp
);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.1.sql
index 10e15fc7b..93ae665e6 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.1.sql
@@ -58,7 +58,9 @@ drop view migtest_e_history6_with_history;
drop trigger table_history_upd;
drop view table_with_history;
-- apply alter tables
+alter table "table" alter column textfield set null;
alter table "table" add column "select" varchar(255);
+alter table "table" add column textfield2 varchar(255);
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -96,7 +98,9 @@ alter table migtest_e_history6 alter column test_number2 set null;
alter table migtest_e_history6_history alter column test_number2 set 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 table_history alter column textfield set null;
alter table table_history add column "select" varchar(255);
+alter table table_history add column textfield2 varchar(255);
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
@@ -161,3 +165,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on "table" (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.3.sql
index 7d0188eed..844fb66bd 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.3.sql
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
+drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.4__dropsFor_1.3.sql
index feea9437a..e7863869a 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.4__dropsFor_1.3.sql
@@ -9,7 +9,11 @@ drop trigger migtest_e_history2_history_upd;
drop view migtest_e_history2_with_history;
drop trigger migtest_e_history5_history_upd;
drop view migtest_e_history5_with_history;
+drop trigger table_history_upd;
+drop view table_with_history;
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -30,11 +34,15 @@ alter table migtest_e_history5 drop column test_boolean;
alter table migtest_e_history5_history drop column test_boolean;
alter table migtest_e_softdelete drop column deleted;
alter table migtest_oto_child drop column master_id;
+alter table table_history drop column textfield;
+alter table table_history drop column textfield2;
-- apply post alter
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history;
create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.platform.h2.H2HistoryTrigger";
+create view table_with_history as select * from "table" union all select * from table_history;
+create trigger table_history_upd before update,delete on "table" for each row call "io.ebean.platform.h2.H2HistoryTrigger";
drop table if exists migtest_e_user;
drop sequence if exists migtest_e_user_seq;
drop table if exists migtest_mtm_c_migtest_mtm_m;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/idx_h2.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/idx_h2.migrations
index e7d2d1dc7..a58bd9139 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/idx_h2.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/idx_h2.migrations
@@ -1,8 +1,8 @@
--1806036603, 1.0__initial.sql
--1296236140, 1.1.sql
+-1854589550, 1.0__initial.sql
+1979519453, 1.1.sql
1579867974, 1.2__dropsFor_1.1.sql
--877392737, 1.3.sql
-116139207, 1.4__dropsFor_1.3.sql
+-285485598, 1.3.sql
+-1120611041, 1.4__dropsFor_1.3.sql
783227075, R__multi_comments.sql
561281075, R__order_views.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.0__initial.sql
index a6b08b371..2c4188555 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.0__initial.sql
@@ -156,6 +156,7 @@ create column table "table" (
"to" nvarchar(255),
"varchar" nvarchar(255),
"foreign" nvarchar(255),
+ textfield nvarchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -257,6 +258,7 @@ create column table table_history (
"to" nvarchar(255),
"varchar" nvarchar(255),
"foreign" nvarchar(255),
+ textfield nvarchar(255) not null,
sys_period_start timestamp,
sys_period_end timestamp
);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.1.sql
index 00f9b2570..98d826685 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.1.sql
@@ -100,7 +100,9 @@ update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
alter table migtest_e_history6 drop system versioning;
alter table "table" drop system versioning;
-- apply alter tables
-alter table "table" add ("select" nvarchar(255));
+alter table "table" alter (textfield nvarchar(255));
+alter table "table" add ("select" nvarchar(255),
+ textfield2 nvarchar(255));
alter table migtest_ckey_detail add (one_key integer,
two_key nvarchar(127));
alter table migtest_ckey_parent add (assoc_id integer);
@@ -130,7 +132,9 @@ alter table migtest_e_history6 alter (test_number1 integer default 42 not null,
alter table migtest_e_history6_history alter (test_number2 integer);
alter table migtest_e_softdelete add (deleted boolean default false not null);
alter table migtest_oto_child add (master_id bigint);
-alter table table_history add ("select" nvarchar(255));
+alter table table_history alter (textfield nvarchar(255));
+alter table table_history add ("select" nvarchar(255),
+ textfield2 nvarchar(255));
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
-- cannot create unique index "uq_migtest_e_basic_description" on table "migtest_e_basic" with nullable columns;
@@ -192,3 +196,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
-- explicit index "ix_migtest_e_basic_indextest3" for single column "indextest3" of table "migtest_e_basic" is not necessary;
-- explicit index "ix_migtest_e_basic_indextest6" for single column "indextest6" of table "migtest_e_basic" is not necessary;
+-- explicit index "ix_table_textfield2" for single column "textfield2" of table ""table"" is not necessary;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.3.sql
index 228ebaa58..e818117ed 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.3.sql
@@ -76,6 +76,13 @@ declare exit handler for sql_error_code 261 begin end;
exec 'drop index ix_migtest_e_basic_indextest6';
end;
$$;
+delimiter $$
+do
+begin
+declare exit handler for sql_error_code 261 begin end;
+exec 'drop index ix_table_textfield2';
+end;
+$$;
-- apply changes
create column table "migtest_QuOtEd" (
id nvarchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.4__dropsFor_1.3.sql
index d49afa4be..801ddd022 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/1.4__dropsFor_1.3.sql
@@ -7,7 +7,10 @@ drop table migtest_e_history_history cascade;
-- apply changes
alter table migtest_e_history2 drop system versioning;
alter table migtest_e_history5 drop system versioning;
+alter table "table" drop system versioning;
-- apply alter tables
+CALL usp_ebean_drop_column('"table"', 'textfield');
+CALL usp_ebean_drop_column('"table"', 'textfield2');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'one_key');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'two_key');
CALL usp_ebean_drop_column('migtest_ckey_parent', 'assoc_id');
@@ -26,9 +29,12 @@ CALL usp_ebean_drop_column('migtest_e_history5', 'test_boolean');
CALL usp_ebean_drop_column('migtest_e_history5_history', 'test_boolean');
CALL usp_ebean_drop_column('migtest_e_softdelete', 'deleted');
CALL usp_ebean_drop_column('migtest_oto_child', 'master_id');
+CALL usp_ebean_drop_column('table_history', 'textfield');
+CALL usp_ebean_drop_column('table_history', 'textfield2');
-- apply post alter
alter table migtest_e_history2 add system versioning history table migtest_e_history2_history not validated;
alter table migtest_e_history5 add system versioning history table migtest_e_history5_history not validated;
+alter table "table" add system versioning history table table_history not validated;
drop table migtest_e_user cascade;
drop table migtest_mtm_c_migtest_mtm_m cascade;
drop table migtest_mtm_m_migtest_mtm_c cascade;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/idx_hana.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/idx_hana.migrations
index 10183c98f..467fc71ec 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/hana/idx_hana.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hana/idx_hana.migrations
@@ -1,8 +1,8 @@
-745347271, I__create_procs.sql
-1631114894, 1.0__initial.sql
--534043487, 1.1.sql
+-2017770851, 1.0__initial.sql
+-1727762906, 1.1.sql
1535221752, 1.2__dropsFor_1.1.sql
-483907844, 1.3.sql
-1812245353, 1.4__dropsFor_1.3.sql
+-1046661128, 1.3.sql
+1185007986, 1.4__dropsFor_1.3.sql
1906063401, R__order_views_hana.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.0__initial.sql
index f84501c10..ff2f34299 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.0__initial.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.1.sql
index 03c8737c7..94010fa00 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.1.sql
@@ -46,7 +46,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
+alter table "table" alter column textfield set null;
alter table "table" add column "select" varchar(255);
+alter table "table" add column textfield2 varchar(255);
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -119,3 +121,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on "table" (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.3.sql
index de92cd16f..3d4fb1409 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.3.sql
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
+drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.4__dropsFor_1.3.sql
index 19c77f211..9387dec42 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/1.4__dropsFor_1.3.sql
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/idx_hsqldb.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/idx_hsqldb.migrations
index 97e572937..61c09dc8e 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/idx_hsqldb.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/hsqldb/idx_hsqldb.migrations
@@ -1,7 +1,7 @@
--906026927, 1.0__initial.sql
-936644233, 1.1.sql
+1833930558, 1.0__initial.sql
+84224587, 1.1.sql
-848622216, 1.2__dropsFor_1.1.sql
-781720387, 1.3.sql
--972999284, 1.4__dropsFor_1.3.sql
+19356381, 1.3.sql
+1661935263, 1.4__dropsFor_1.3.sql
861001272, R__order_views_hsqldb.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.0__initial.sql
index be0dfa028..f9b1b3f43 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.0__initial.sql
@@ -151,6 +151,7 @@ create table `table` (
`to` varchar(255),
`varchar` varchar(255),
`foreign` varchar(255),
+ textfield varchar(255) not null,
constraint uq_table_to unique (`to`),
constraint uq_table_varchar unique (`varchar`),
constraint pk_table primary key (`index`)
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.1.sql
index 1f6356a45..4213de18e 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.1.sql
@@ -44,7 +44,9 @@ SET @@system_versioning_alter_history = 1;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
+alter table `table` modify textfield varchar(255);
alter table `table` add column `select` varchar(255);
+alter table `table` add column textfield2 varchar(255);
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -108,3 +110,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on `table` (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.3.sql
index fc633abc6..6fd34becb 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.3.sql
@@ -13,6 +13,7 @@ alter table migtest_e_basic drop index uq_migtest_e_basic_indextest4;
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest5;
drop index ix_migtest_e_basic_indextest3 on migtest_e_basic;
drop index ix_migtest_e_basic_indextest6 on migtest_e_basic;
+drop index ix_table_textfield2 on `table`;
-- apply changes
create table `migtest_QuOtEd` (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.4__dropsFor_1.3.sql
index b15ac579e..2f4425f31 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/1.4__dropsFor_1.3.sql
@@ -2,6 +2,8 @@
-- apply changes
SET @@system_versioning_alter_history = 1;
-- apply alter tables
+alter table `table` drop column textfield;
+alter table `table` drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/idx_mariadb.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/idx_mariadb.migrations
index d56859c0a..98022f4e3 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/idx_mariadb.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb-noprocs/idx_mariadb.migrations
@@ -1,7 +1,7 @@
-168258180, 1.0__initial.sql
-1552926718, 1.1.sql
+-2111548334, 1.0__initial.sql
+-1101751768, 1.1.sql
919151678, 1.2__dropsFor_1.1.sql
--1031408459, 1.3.sql
--446860935, 1.4__dropsFor_1.3.sql
+-1572621686, 1.3.sql
+1686135364, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.0__initial.sql
index be0dfa028..f9b1b3f43 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.0__initial.sql
@@ -151,6 +151,7 @@ create table `table` (
`to` varchar(255),
`varchar` varchar(255),
`foreign` varchar(255),
+ textfield varchar(255) not null,
constraint uq_table_to unique (`to`),
constraint uq_table_varchar unique (`varchar`),
constraint pk_table primary key (`index`)
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.1.sql
index 1f6356a45..4213de18e 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.1.sql
@@ -44,7 +44,9 @@ SET @@system_versioning_alter_history = 1;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
+alter table `table` modify textfield varchar(255);
alter table `table` add column `select` varchar(255);
+alter table `table` add column textfield2 varchar(255);
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -108,3 +110,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on `table` (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.3.sql
index fc633abc6..6fd34becb 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.3.sql
@@ -13,6 +13,7 @@ alter table migtest_e_basic drop index uq_migtest_e_basic_indextest4;
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest5;
drop index ix_migtest_e_basic_indextest3 on migtest_e_basic;
drop index ix_migtest_e_basic_indextest6 on migtest_e_basic;
+drop index ix_table_textfield2 on `table`;
-- apply changes
create table `migtest_QuOtEd` (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.4__dropsFor_1.3.sql
index abd31f737..cbc989b87 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/1.4__dropsFor_1.3.sql
@@ -2,6 +2,8 @@
-- apply changes
SET @@system_versioning_alter_history = 1;
-- apply alter tables
+CALL usp_ebean_drop_column('table', 'textfield');
+CALL usp_ebean_drop_column('table', 'textfield2');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'one_key');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'two_key');
CALL usp_ebean_drop_column('migtest_ckey_parent', 'assoc_id');
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/idx_mariadb.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/idx_mariadb.migrations
index 062f003bd..8e5869058 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/idx_mariadb.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mariadb/idx_mariadb.migrations
@@ -1,8 +1,8 @@
1835064798, I__create_procs.sql
-168258180, 1.0__initial.sql
-1552926718, 1.1.sql
+-2111548334, 1.0__initial.sql
+-1101751768, 1.1.sql
1187950993, 1.2__dropsFor_1.1.sql
--1031408459, 1.3.sql
--692020559, 1.4__dropsFor_1.3.sql
+-1572621686, 1.3.sql
+772508824, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.0__initial.model.xml b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.0__initial.model.xml
index c58d005d9..b0d93151a 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.0__initial.model.xml
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.0__initial.model.xml
@@ -112,6 +112,7 @@
+
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.1.model.xml b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.1.model.xml
index 27bfee165..1c704408c 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.1.model.xml
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.1.model.xml
@@ -73,8 +73,10 @@
+
+
@@ -103,6 +105,7 @@
+
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.3.model.xml b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.3.model.xml
index ca95c8f6d..8aac45e36 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.3.model.xml
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.3.model.xml
@@ -61,6 +61,7 @@
+
@@ -77,6 +78,8 @@
+
+
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.4__dropsFor_1.3.model.xml b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.4__dropsFor_1.3.model.xml
index 19dce6648..a18446b1a 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.4__dropsFor_1.3.model.xml
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/model/1.4__dropsFor_1.3.model.xml
@@ -15,6 +15,8 @@
+
+
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.0__initial.sql
index dd9c89e5c..f2eb08f85 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.0__initial.sql
@@ -151,6 +151,7 @@ create table `table` (
`to` varchar(255),
`varchar` varchar(255),
`foreign` varchar(255),
+ textfield varchar(255) not null,
constraint uq_table_to unique (`to`),
constraint uq_table_varchar unique (`varchar`),
constraint pk_table primary key (`index`)
@@ -298,6 +299,7 @@ create table table_history(
`to` varchar(255),
`varchar` varchar(255),
`foreign` varchar(255),
+ textfield varchar(255),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
@@ -305,12 +307,12 @@ create view table_with_history as select * from `table` union all select * from
lock tables `table` write;
delimiter $$
create trigger table_history_upd before update on `table` for each row begin
- insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`);
+ insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`, textfield) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`, OLD.textfield);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger table_history_del before delete on `table` for each row begin
- insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`);
+ insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`, textfield) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`, OLD.textfield);
end$$
unlock tables;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.1.sql
index ea2513195..2b8461633 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.1.sql
@@ -61,7 +61,9 @@ drop trigger table_history_upd;
drop trigger table_history_del;
drop view table_with_history;
-- apply alter tables
+alter table `table` modify textfield varchar(255);
alter table `table` add column `select` varchar(255);
+alter table `table` add column textfield2 varchar(255);
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -93,7 +95,9 @@ alter table migtest_e_history6 modify test_number2 integer;
alter table migtest_e_history6_history modify test_number2 integer;
alter table migtest_e_softdelete add column deleted tinyint(1) default 0 not null;
alter table migtest_oto_child add column master_id bigint;
+alter table table_history modify textfield varchar(255);
alter table table_history add column `select` varchar(255);
+alter table table_history add column textfield2 varchar(255);
-- apply post alter
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
update migtest_e_basic set new_boolean_field = old_boolean;
@@ -186,12 +190,12 @@ create view table_with_history as select * from `table` union all select * from
lock tables `table` write;
delimiter $$
create trigger table_history_upd before update on `table` for each row begin
- insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
+ insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`, textfield, textfield2) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`, OLD.textfield, OLD.textfield2);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger table_history_del before delete on `table` for each row begin
- insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
+ insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`, textfield, textfield2) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`, OLD.textfield, OLD.textfield2);
end$$
unlock tables;
alter table `table` add constraint uq_table_select unique (`select`);
@@ -224,3 +228,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on `table` (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.3.sql
index 59325f7c9..410f3e719 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.3.sql
@@ -13,6 +13,7 @@ alter table migtest_e_basic drop index uq_migtest_e_basic_indextest4;
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest5;
drop index ix_migtest_e_basic_indextest3 on migtest_e_basic;
drop index ix_migtest_e_basic_indextest6 on migtest_e_basic;
+drop index ix_table_textfield2 on `table`;
-- apply changes
create table `migtest_QuOtEd` (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.4__dropsFor_1.3.sql
index 0cde3c7b2..f98131f6f 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/1.4__dropsFor_1.3.sql
@@ -12,7 +12,12 @@ drop view migtest_e_history2_with_history;
drop trigger migtest_e_history5_history_upd;
drop trigger migtest_e_history5_history_del;
drop view migtest_e_history5_with_history;
+drop trigger table_history_upd;
+drop trigger table_history_del;
+drop view table_with_history;
-- apply alter tables
+CALL usp_ebean_drop_column('table', 'textfield');
+CALL usp_ebean_drop_column('table', 'textfield2');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'one_key');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'two_key');
CALL usp_ebean_drop_column('migtest_ckey_parent', 'assoc_id');
@@ -33,6 +38,8 @@ CALL usp_ebean_drop_column('migtest_e_history5', 'test_boolean');
CALL usp_ebean_drop_column('migtest_e_history5_history', 'test_boolean');
CALL usp_ebean_drop_column('migtest_e_softdelete', 'deleted');
CALL usp_ebean_drop_column('migtest_oto_child', 'master_id');
+CALL usp_ebean_drop_column('table_history', 'textfield');
+CALL usp_ebean_drop_column('table_history', 'textfield2');
-- apply post alter
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
lock tables migtest_e_history2 write;
@@ -58,6 +65,18 @@ create trigger migtest_e_history5_history_del before delete on migtest_e_history
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
end$$
unlock tables;
+create view table_with_history as select * from `table` union all select * from table_history;
+lock tables `table` write;
+delimiter $$
+create trigger table_history_upd before update on `table` for each row begin
+ insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
+ set NEW.sys_period_start = now(6);
+end$$
+delimiter $$
+create trigger table_history_del before delete on `table` for each row begin
+ insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
+end$$
+unlock tables;
drop table if exists migtest_e_user;
drop table if exists migtest_mtm_c_migtest_mtm_m;
drop table if exists migtest_mtm_m_migtest_mtm_c;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/idx_mysql.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/idx_mysql.migrations
index 95bc6e4eb..a34680253 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/idx_mysql.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql/idx_mysql.migrations
@@ -1,8 +1,8 @@
1835064798, I__create_procs.sql
-776107385, 1.0__initial.sql
--1234435534, 1.1.sql
+1980830787, 1.0__initial.sql
+-92753611, 1.1.sql
-1097227916, 1.2__dropsFor_1.1.sql
--1972055805, 1.3.sql
-379252952, 1.4__dropsFor_1.3.sql
+1674664705, 1.3.sql
+-1282113429, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.0__initial.sql
index 47f10a181..b1db29fc1 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.0__initial.sql
@@ -151,6 +151,7 @@ create table `table` (
`to` varchar(255),
`varchar` varchar(255),
`foreign` varchar(255),
+ textfield varchar(255) not null,
constraint uq_table_to unique (`to`),
constraint uq_table_varchar unique (`varchar`),
constraint pk_table primary key (`index`)
@@ -298,6 +299,7 @@ create table table_history(
`to` varchar(255),
`varchar` varchar(255),
`foreign` varchar(255),
+ textfield varchar(255),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
@@ -305,12 +307,12 @@ create view table_with_history as select * from `table` union all select * from
lock tables `table` write;
delimiter $$
create trigger table_history_upd before update on `table` for each row begin
- insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`);
+ insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`, textfield) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`, OLD.textfield);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger table_history_del before delete on `table` for each row begin
- insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`);
+ insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `foreign`, textfield) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`foreign`, OLD.textfield);
end$$
unlock tables;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.1.sql
index ea2513195..2b8461633 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.1.sql
@@ -61,7 +61,9 @@ drop trigger table_history_upd;
drop trigger table_history_del;
drop view table_with_history;
-- apply alter tables
+alter table `table` modify textfield varchar(255);
alter table `table` add column `select` varchar(255);
+alter table `table` add column textfield2 varchar(255);
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -93,7 +95,9 @@ alter table migtest_e_history6 modify test_number2 integer;
alter table migtest_e_history6_history modify test_number2 integer;
alter table migtest_e_softdelete add column deleted tinyint(1) default 0 not null;
alter table migtest_oto_child add column master_id bigint;
+alter table table_history modify textfield varchar(255);
alter table table_history add column `select` varchar(255);
+alter table table_history add column textfield2 varchar(255);
-- apply post alter
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
update migtest_e_basic set new_boolean_field = old_boolean;
@@ -186,12 +190,12 @@ create view table_with_history as select * from `table` union all select * from
lock tables `table` write;
delimiter $$
create trigger table_history_upd before update on `table` for each row begin
- insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
+ insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`, textfield, textfield2) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`, OLD.textfield, OLD.textfield2);
set NEW.sys_period_start = now(6);
end$$
delimiter $$
create trigger table_history_del before delete on `table` for each row begin
- insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
+ insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`, textfield, textfield2) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`, OLD.textfield, OLD.textfield2);
end$$
unlock tables;
alter table `table` add constraint uq_table_select unique (`select`);
@@ -224,3 +228,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on `table` (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.3.sql
index 59325f7c9..410f3e719 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.3.sql
@@ -13,6 +13,7 @@ alter table migtest_e_basic drop index uq_migtest_e_basic_indextest4;
alter table migtest_e_basic drop index uq_migtest_e_basic_indextest5;
drop index ix_migtest_e_basic_indextest3 on migtest_e_basic;
drop index ix_migtest_e_basic_indextest6 on migtest_e_basic;
+drop index ix_table_textfield2 on `table`;
-- apply changes
create table `migtest_QuOtEd` (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.4__dropsFor_1.3.sql
index 0cde3c7b2..f98131f6f 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/1.4__dropsFor_1.3.sql
@@ -12,7 +12,12 @@ drop view migtest_e_history2_with_history;
drop trigger migtest_e_history5_history_upd;
drop trigger migtest_e_history5_history_del;
drop view migtest_e_history5_with_history;
+drop trigger table_history_upd;
+drop trigger table_history_del;
+drop view table_with_history;
-- apply alter tables
+CALL usp_ebean_drop_column('table', 'textfield');
+CALL usp_ebean_drop_column('table', 'textfield2');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'one_key');
CALL usp_ebean_drop_column('migtest_ckey_detail', 'two_key');
CALL usp_ebean_drop_column('migtest_ckey_parent', 'assoc_id');
@@ -33,6 +38,8 @@ CALL usp_ebean_drop_column('migtest_e_history5', 'test_boolean');
CALL usp_ebean_drop_column('migtest_e_history5_history', 'test_boolean');
CALL usp_ebean_drop_column('migtest_e_softdelete', 'deleted');
CALL usp_ebean_drop_column('migtest_oto_child', 'master_id');
+CALL usp_ebean_drop_column('table_history', 'textfield');
+CALL usp_ebean_drop_column('table_history', 'textfield2');
-- apply post alter
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
lock tables migtest_e_history2 write;
@@ -58,6 +65,18 @@ create trigger migtest_e_history5_history_del before delete on migtest_e_history
insert into migtest_e_history5_history (sys_period_start,sys_period_end,id, test_number) values (OLD.sys_period_start, now(6),OLD.id, OLD.test_number);
end$$
unlock tables;
+create view table_with_history as select * from `table` union all select * from table_history;
+lock tables `table` write;
+delimiter $$
+create trigger table_history_upd before update on `table` for each row begin
+ insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
+ set NEW.sys_period_start = now(6);
+end$$
+delimiter $$
+create trigger table_history_del before delete on `table` for each row begin
+ insert into table_history (sys_period_start,sys_period_end,`index`, `from`, `to`, `varchar`, `select`, `foreign`) values (OLD.sys_period_start, now(6),OLD.`index`, OLD.`from`, OLD.`to`, OLD.`varchar`, OLD.`select`, OLD.`foreign`);
+end$$
+unlock tables;
drop table if exists migtest_e_user;
drop table if exists migtest_mtm_c_migtest_mtm_m;
drop table if exists migtest_mtm_m_migtest_mtm_c;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/idx_mysql.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/idx_mysql.migrations
index 29cc0fd02..9a86b08df 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/idx_mysql.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/mysql55/idx_mysql.migrations
@@ -1,8 +1,8 @@
1835064798, I__create_procs.sql
--1717521141, 1.0__initial.sql
--1234435534, 1.1.sql
+369577572, 1.0__initial.sql
+-92753611, 1.1.sql
-1097227916, 1.2__dropsFor_1.1.sql
--1972055805, 1.3.sql
-379252952, 1.4__dropsFor_1.3.sql
+1674664705, 1.3.sql
+-1282113429, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.0__initial.sql
index 02cb7f494..b5d81c5bd 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.0__initial.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -313,6 +314,7 @@ create table table_history(
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255),
sys_period_start datetime(6),
sys_period_end datetime(6)
);
@@ -320,13 +322,13 @@ create view table_with_history as select * from "table" union all select * from
delimiter $$
create or replace trigger table_history_upd for "table" before update for each row as
NEW.sys_period_start = greatest(current_timestamp, date_add(OLD.sys_period_start, interval 1 microsecond));
- insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "foreign") values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign");
+ insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "foreign", textfield) values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign", OLD.textfield);
end_trigger;
$$
delimiter $$
create or replace trigger table_history_del for "table" before delete for each row as
- insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "foreign") values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign");
+ insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "foreign", textfield) values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign", OLD.textfield);
end_trigger;
$$
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.1.sql
index 2261591dd..31cdd3756 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.1.sql
@@ -64,7 +64,9 @@ drop trigger table_history_upd;
drop trigger table_history_del;
drop view table_with_history;
-- apply alter tables
+alter table "table" alter column textfield set null;
alter table "table" add column "select" varchar(255);
+alter table "table" add column textfield2 varchar(255);
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -102,7 +104,9 @@ alter table migtest_e_history6 alter column test_number2 set null;
alter table migtest_e_history6_history alter column test_number2 set 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 table_history alter column textfield set null;
alter table table_history add column "select" varchar(255);
+alter table table_history add column textfield2 varchar(255);
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
@@ -208,13 +212,13 @@ create view table_with_history as select * from "table" union all select * from
delimiter $$
create or replace trigger table_history_upd for "table" before update for each row as
NEW.sys_period_start = greatest(current_timestamp, date_add(OLD.sys_period_start, interval 1 microsecond));
- insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "select", "foreign") values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+ insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "select", "foreign", textfield, textfield2) values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign", OLD.textfield, OLD.textfield2);
end_trigger;
$$
delimiter $$
create or replace trigger table_history_del for "table" before delete for each row as
- insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "select", "foreign") values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+ insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "select", "foreign", textfield, textfield2) values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign", OLD.textfield, OLD.textfield2);
end_trigger;
$$
@@ -248,3 +252,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on "table" (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.3.sql
index 53837ffc5..ca422f7c7 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.3.sql
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
+drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.4__dropsFor_1.3.sql
index feeb1d7cf..257fb38bd 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/1.4__dropsFor_1.3.sql
@@ -12,7 +12,12 @@ drop view migtest_e_history2_with_history;
drop trigger migtest_e_history5_history_upd;
drop trigger migtest_e_history5_history_del;
drop view migtest_e_history5_with_history;
+drop trigger table_history_upd;
+drop trigger table_history_del;
+drop view table_with_history;
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -33,6 +38,8 @@ alter table migtest_e_history5 drop column test_boolean;
alter table migtest_e_history5_history drop column test_boolean;
alter table migtest_e_softdelete drop column deleted;
alter table migtest_oto_child drop column master_id;
+alter table table_history drop column textfield;
+alter table table_history drop column textfield2;
-- apply post alter
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
delimiter $$
@@ -62,6 +69,20 @@ create or replace trigger migtest_e_history5_history_del for migtest_e_history5
end_trigger;
$$
+create view table_with_history as select * from "table" union all select * from table_history;
+delimiter $$
+create or replace trigger table_history_upd for "table" before update for each row as
+ NEW.sys_period_start = greatest(current_timestamp, date_add(OLD.sys_period_start, interval 1 microsecond));
+ insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "select", "foreign") values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+end_trigger;
+$$
+
+delimiter $$
+create or replace trigger table_history_del for "table" before delete for each row as
+ insert into table_history (sys_period_start,sys_period_end,"index", "from", "to", "varchar", "select", "foreign") values (OLD.sys_period_start, NEW.sys_period_start,OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+end_trigger;
+$$
+
drop table if exists migtest_e_user;
drop sequence if exists migtest_e_user_seq;
drop table if exists migtest_mtm_c_migtest_mtm_m;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/idx_nuodb.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/idx_nuodb.migrations
index 3a4cbeb55..1342d6508 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/idx_nuodb.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/nuodb/idx_nuodb.migrations
@@ -1,7 +1,7 @@
--355978970, 1.0__initial.sql
--667611059, 1.1.sql
+390216918, 1.0__initial.sql
+-2079708895, 1.1.sql
1530685455, 1.2__dropsFor_1.1.sql
-1263834751, 1.3.sql
--1189704269, 1.4__dropsFor_1.3.sql
+73983167, 1.3.sql
+-1118858496, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.0__initial.sql
index ced9cf2cd..4b2f1f9a5 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.0__initial.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar2(255),
"varchar" varchar2(255),
"foreign" varchar2(255),
+ textfield varchar2(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.1.sql
index f67704c3e..f78c04b78 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.1.sql
@@ -91,7 +91,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
+alter table "table" modify textfield null;
alter table "table" add "select" varchar2(255);
+alter table "table" add textfield2 varchar2(255);
alter table migtest_ckey_detail add one_key number(10);
alter table migtest_ckey_detail add two_key varchar2(127);
alter table migtest_ckey_parent add assoc_id number(10);
@@ -164,3 +166,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on "table" (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.3.sql
index 14204acde..ada955aab 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.3.sql
@@ -88,6 +88,7 @@ end;
$$;
drop index ix_migtest_e_basic_indextest3;
drop index ix_migtest_e_basic_indextest6;
+drop index ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar2(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.4__dropsFor_1.3.sql
index 38e77cae7..57b6f9a7e 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/1.4__dropsFor_1.3.sql
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/idx_oracle.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/idx_oracle.migrations
index cf60af39b..160b8b601 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/idx_oracle.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle/idx_oracle.migrations
@@ -1,8 +1,8 @@
-1374133214, 1.0__initial.sql
--2091161947, 1.1.sql
+1757923548, 1.0__initial.sql
+740264587, 1.1.sql
930172034, 1.2__dropsFor_1.1.sql
--1621367223, 1.3.sql
-663051206, 1.4__dropsFor_1.3.sql
+-1896525025, 1.3.sql
+2037899598, 1.4__dropsFor_1.3.sql
1357801733, R__oracle_only_views.sql
561281075, R__order_views.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.0__initial.sql
index aeb4dc5a7..bfbc238c4 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.0__initial.sql
@@ -174,6 +174,7 @@ create table "table" (
"to" varchar2(255),
"varchar" varchar2(255),
"foreign" varchar2(255),
+ textfield varchar2(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.1.sql
index 9088fa48b..7a24eef36 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.1.sql
@@ -92,7 +92,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
+alter table "table" modify textfield null;
alter table "table" add "select" varchar2(255);
+alter table "table" add textfield2 varchar2(255);
alter table migtest_ckey_detail add one_key number(10);
alter table migtest_ckey_detail add two_key varchar2(127);
alter table migtest_ckey_parent add assoc_id number(10);
@@ -165,3 +167,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on "table" (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.3.sql
index 97091b812..60e60243b 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.3.sql
@@ -88,6 +88,7 @@ end;
$$;
drop index ix_migtest_e_basic_indextest3;
drop index ix_migtest_e_basic_indextest6;
+drop index ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar2(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.4__dropsFor_1.3.sql
index 38e77cae7..57b6f9a7e 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/1.4__dropsFor_1.3.sql
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/idx_oracle.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/idx_oracle.migrations
index d50ab5194..3095da37b 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/idx_oracle.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/oracle11/idx_oracle.migrations
@@ -1,8 +1,8 @@
-1070168506, 1.0__initial.sql
--1116696749, 1.1.sql
+-1422254768, 1.0__initial.sql
+-123689547, 1.1.sql
930172034, 1.2__dropsFor_1.1.sql
--144959080, 1.3.sql
-663051206, 1.4__dropsFor_1.3.sql
+1967473644, 1.3.sql
+2037899598, 1.4__dropsFor_1.3.sql
1357801733, R__oracle_only_views.sql
561281075, R__order_views.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.0__initial.sql
index 1fc2b0f70..766e79bca 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.0__initial.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -329,11 +330,11 @@ begin
lowerTs = lower(OLD.sys_period);
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
if (TG_OP = 'UPDATE') then
- insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign");
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign", textfield) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign", OLD.textfield);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
- insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign");
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign", textfield) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign", OLD.textfield);
return old;
end if;
end;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.1.sql
index 43517b9ee..4bdf82afc 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.1.sql
@@ -75,7 +75,9 @@ drop function if exists table_history_version();
drop view table_with_history;
-- apply alter tables
+alter table "table" alter column textfield drop not null;
alter table "table" add column "select" varchar(255);
+alter table "table" add column textfield2 varchar(255);
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -112,7 +114,9 @@ alter table migtest_e_history6 alter column test_number2 drop not null;
alter table migtest_e_history6_history alter column test_number2 drop not null;
alter table migtest_e_softdelete add column deleted boolean default false not null;
alter table migtest_oto_child add column master_id bigint;
+alter table table_history alter column textfield drop not null;
alter table table_history add column "select" varchar(255);
+alter table table_history add column textfield2 varchar(255);
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
@@ -275,11 +279,11 @@ begin
lowerTs = lower(OLD.sys_period);
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
if (TG_OP = 'UPDATE') then
- insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign", textfield, textfield2) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign", OLD.textfield, OLD.textfield2);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
- insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign", textfield, textfield2) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign", OLD.textfield, OLD.textfield2);
return old;
end if;
end;
@@ -319,4 +323,5 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index if not exists ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index if not exists ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
+create index if not exists ix_table_textfield2 on "table" (textfield2);
create index if not exists ix_migtest_oto_child_name on migtest_oto_child (name);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.3.sql
index 585f3ffb6..e024c1aa3 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.3.sql
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
+drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.4__dropsFor_1.3.sql
index 822e9f61a..abf1cd14d 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/1.4__dropsFor_1.3.sql
@@ -15,7 +15,13 @@ drop trigger if exists migtest_e_history5_history_upd on migtest_e_history5 casc
drop function if exists migtest_e_history5_history_version();
drop view migtest_e_history5_with_history;
+drop trigger if exists table_history_upd on "table" cascade;
+drop function if exists table_history_version();
+
+drop view table_with_history;
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -35,6 +41,8 @@ alter table migtest_e_history5 drop column test_boolean;
alter table migtest_e_history5_history drop column test_boolean;
alter table migtest_e_softdelete drop column deleted;
alter table migtest_oto_child drop column master_id;
+alter table table_history drop column textfield;
+alter table table_history drop column textfield2;
-- apply post alter
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
create or replace function migtest_e_history2_history_version() returns trigger as $$
@@ -82,6 +90,29 @@ create trigger migtest_e_history5_history_upd
before update or delete on migtest_e_history5
for each row execute procedure migtest_e_history5_history_version();
+create view table_with_history as select * from "table" union all select * from table_history;
+create or replace function table_history_version() returns trigger as $$
+declare
+ lowerTs timestamptz;
+ upperTs timestamptz;
+begin
+ lowerTs = lower(OLD.sys_period);
+ upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
+ if (TG_OP = 'UPDATE') then
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+ NEW.sys_period = tstzrange(upperTs,null);
+ return new;
+ elsif (TG_OP = 'DELETE') then
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+ return old;
+ end if;
+end;
+$$ LANGUAGE plpgsql;
+
+create trigger table_history_upd
+ before update or delete on "table"
+ for each row execute procedure table_history_version();
+
drop table if exists migtest_e_user cascade;
drop sequence if exists migtest_e_user_seq;
drop table if exists migtest_mtm_c_migtest_mtm_m cascade;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/idx_postgres.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/idx_postgres.migrations
index 1ef12b383..06ebb0b61 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/idx_postgres.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres/idx_postgres.migrations
@@ -1,8 +1,8 @@
-2094204208, 1.0__initial.sql
--1092950076, 1.1.sql
+-769462329, 1.0__initial.sql
+409812555, 1.1.sql
-261111052, 1.2__dropsFor_1.1.sql
-1335621453, 1.3.sql
-1729345905, 1.4__dropsFor_1.3.sql
+1214144459, 1.3.sql
+-709144111, 1.4__dropsFor_1.3.sql
783227075, R__multi_comments.sql
561281075, R__order_views.sql
283077354, R__pg_indexes.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.0__initial.sql
index a9869f95b..21fa13691 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.0__initial.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -329,11 +330,11 @@ begin
lowerTs = lower(OLD.sys_period);
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
if (TG_OP = 'UPDATE') then
- insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign");
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign", textfield) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign", OLD.textfield);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
- insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign");
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign", textfield) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign", OLD.textfield);
return old;
end if;
end;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.1.sql
index aaa3fd79b..4cf767c51 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.1.sql
@@ -75,7 +75,9 @@ drop function if exists table_history_version();
drop view table_with_history;
-- apply alter tables
+alter table "table" alter column textfield drop not null;
alter table "table" add column "select" varchar(255);
+alter table "table" add column textfield2 varchar(255);
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -112,7 +114,9 @@ alter table migtest_e_history6 alter column test_number2 drop not null;
alter table migtest_e_history6_history alter column test_number2 drop not null;
alter table migtest_e_softdelete add column deleted boolean default false not null;
alter table migtest_oto_child add column master_id bigint;
+alter table table_history alter column textfield drop not null;
alter table table_history add column "select" varchar(255);
+alter table table_history add column textfield2 varchar(255);
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
@@ -275,11 +279,11 @@ begin
lowerTs = lower(OLD.sys_period);
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
if (TG_OP = 'UPDATE') then
- insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign", textfield, textfield2) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign", OLD.textfield, OLD.textfield2);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
- insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign", textfield, textfield2) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign", OLD.textfield, OLD.textfield2);
return old;
end if;
end;
@@ -319,4 +323,5 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index if not exists ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index if not exists ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
+create index if not exists ix_table_textfield2 on "table" (textfield2);
create index if not exists ix_migtest_oto_child_name on migtest_oto_child (name);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.3.sql
index 401b5a211..eba9fb564 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.3.sql
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
+drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.4__dropsFor_1.3.sql
index 822e9f61a..abf1cd14d 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/1.4__dropsFor_1.3.sql
@@ -15,7 +15,13 @@ drop trigger if exists migtest_e_history5_history_upd on migtest_e_history5 casc
drop function if exists migtest_e_history5_history_version();
drop view migtest_e_history5_with_history;
+drop trigger if exists table_history_upd on "table" cascade;
+drop function if exists table_history_version();
+
+drop view table_with_history;
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -35,6 +41,8 @@ alter table migtest_e_history5 drop column test_boolean;
alter table migtest_e_history5_history drop column test_boolean;
alter table migtest_e_softdelete drop column deleted;
alter table migtest_oto_child drop column master_id;
+alter table table_history drop column textfield;
+alter table table_history drop column textfield2;
-- apply post alter
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
create or replace function migtest_e_history2_history_version() returns trigger as $$
@@ -82,6 +90,29 @@ create trigger migtest_e_history5_history_upd
before update or delete on migtest_e_history5
for each row execute procedure migtest_e_history5_history_version();
+create view table_with_history as select * from "table" union all select * from table_history;
+create or replace function table_history_version() returns trigger as $$
+declare
+ lowerTs timestamptz;
+ upperTs timestamptz;
+begin
+ lowerTs = lower(OLD.sys_period);
+ upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
+ if (TG_OP = 'UPDATE') then
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+ NEW.sys_period = tstzrange(upperTs,null);
+ return new;
+ elsif (TG_OP = 'DELETE') then
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+ return old;
+ end if;
+end;
+$$ LANGUAGE plpgsql;
+
+create trigger table_history_upd
+ before update or delete on "table"
+ for each row execute procedure table_history_version();
+
drop table if exists migtest_e_user cascade;
drop sequence if exists migtest_e_user_seq;
drop table if exists migtest_mtm_c_migtest_mtm_m cascade;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/idx_postgres.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/idx_postgres.migrations
index 8c262040d..5136723e3 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/idx_postgres.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/postgres9/idx_postgres.migrations
@@ -1,8 +1,8 @@
--231429368, 1.0__initial.sql
-1978065929, 1.1.sql
+-309942302, 1.0__initial.sql
+2116598611, 1.1.sql
-261111052, 1.2__dropsFor_1.1.sql
--893728811, 1.3.sql
-1729345905, 1.4__dropsFor_1.3.sql
+-388526579, 1.3.sql
+-709144111, 1.4__dropsFor_1.3.sql
783227075, R__multi_comments.sql
561281075, R__order_views.sql
283077354, R__pg_indexes.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.0__initial.sql
index 6f14a9835..3d79a3500 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.0__initial.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.1.sql
index 86c17934e..f6c2af545 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.1.sql
@@ -46,7 +46,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
+alter table "table" alter column textfield set null;
alter table "table" add column "select" varchar(255);
+alter table "table" add column textfield2 varchar(255);
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -119,3 +121,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on "table" (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.3.sql
index e028819d5..88a290c0f 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.3.sql
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
+drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.4__dropsFor_1.3.sql
index b4087d6d6..b7d11cb4d 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/1.4__dropsFor_1.3.sql
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/idx_sqlanywhere.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/idx_sqlanywhere.migrations
index d402eabae..5c3f07503 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/idx_sqlanywhere.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlanywhere/idx_sqlanywhere.migrations
@@ -1,6 +1,6 @@
-736698620, 1.0__initial.sql
--1254905907, 1.1.sql
+-951189503, 1.0__initial.sql
+128425002, 1.1.sql
688811494, 1.2__dropsFor_1.1.sql
--2020328769, 1.3.sql
-80209848, 1.4__dropsFor_1.3.sql
+-519291959, 1.3.sql
+255653518, 1.4__dropsFor_1.3.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.0__initial.sql
index 0c2e27345..bfd05a961 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.0__initial.sql
@@ -159,6 +159,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index"),
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.1.sql
index 28efd29ab..3c93d203c 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.1.sql
@@ -51,7 +51,9 @@ update migtest_e_history2 set test_string = 'unknown' where test_string is null;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- apply alter tables
+-- not supported: alter table "table" alter column textfield set null;
alter table "table" add column "select" varchar(255);
+alter table "table" add column textfield2 varchar(255);
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -105,3 +107,4 @@ create index ix_migtest_ckey_parent_assoc_id on migtest_ckey_parent (assoc_id);
create index ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
+create index ix_table_textfield2 on "table" (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.3.sql
index 01458d882..791293355 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.3.sql
@@ -16,6 +16,7 @@
-- not supported: alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
+drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.4__dropsFor_1.3.sql
index b4087d6d6..b7d11cb4d 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/1.4__dropsFor_1.3.sql
@@ -1,5 +1,7 @@
-- Migrationscripts for ebean unittest
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/idx_sqlite.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/idx_sqlite.migrations
index 56cae1ad7..6fa5eb1cb 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/idx_sqlite.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlite/idx_sqlite.migrations
@@ -1,7 +1,7 @@
-346470730, 1.0__initial.sql
-35635339, 1.1.sql
+-1527127682, 1.0__initial.sql
+1828386122, 1.1.sql
688811494, 1.2__dropsFor_1.1.sql
-1092030960, 1.3.sql
-80209848, 1.4__dropsFor_1.3.sql
+536935117, 1.3.sql
+255653518, 1.4__dropsFor_1.3.sql
2034589659, R__order_views_sqlite.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.0__initial.sql
index 756c7bce8..b57f44881 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.0__initial.sql
@@ -152,6 +152,7 @@ create table [table] (
[to] varchar(255),
[varchar] varchar(255),
[foreign] varchar(255),
+ textfield varchar(255) not null,
constraint pk_table primary key ([index])
);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.1.sql
index a2de5c9f5..015546583 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.1.sql
@@ -66,7 +66,9 @@ update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- history migration goes here
-- alter table [table] set (system_versioning = on (history_table=dbo.table_history));
-- apply alter tables
+alter table [table] alter column textfield varchar(255);
alter table [table] add [select] varchar(255);
+alter table [table] add textfield2 varchar(255);
alter table migtest_ckey_detail add one_key integer;
alter table migtest_ckey_detail add two_key varchar(127);
alter table migtest_ckey_parent add assoc_id integer;
@@ -143,3 +145,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on [table] (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.3.sql
index 7802b1395..cdbfa5810 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.3.sql
@@ -21,6 +21,7 @@ IF OBJECT_ID('uq_migtest_e_basic_indextest5', 'UQ') IS NOT NULL alter table migt
IF OBJECT_ID('ck_migtest_e_enum_test_status', 'C') IS NOT NULL alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status;
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest3') drop index ix_migtest_e_basic_indextest3 ON migtest_e_basic;
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest6') drop index ix_migtest_e_basic_indextest6 ON migtest_e_basic;
+IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('"table"','U') AND name = 'ix_table_textfield2') drop index ix_table_textfield2 ON "table";
-- apply changes
create table [migtest_QuOtEd] (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.4__dropsFor_1.3.sql
index 00b08667c..feeefad50 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/1.4__dropsFor_1.3.sql
@@ -10,7 +10,12 @@ alter table migtest_e_history drop period for system_time;
-- alter table migtest_e_history5 set (system_versioning = off (history_table=dbo.migtest_e_history5_history));
-- history migration goes here
-- alter table migtest_e_history5 set (system_versioning = on (history_table=dbo.migtest_e_history5_history));
+-- alter table [table] set (system_versioning = off (history_table=dbo.table_history));
+-- history migration goes here
+-- alter table [table] set (system_versioning = on (history_table=dbo.table_history));
-- apply alter tables
+EXEC usp_ebean_drop_column "table", textfield;
+EXEC usp_ebean_drop_column "table", textfield2;
EXEC usp_ebean_drop_column migtest_ckey_detail, one_key;
EXEC usp_ebean_drop_column migtest_ckey_detail, two_key;
EXEC usp_ebean_drop_column migtest_ckey_parent, assoc_id;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/idx_sqlserver.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/idx_sqlserver.migrations
index d82f304dc..813d7aa4c 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/idx_sqlserver.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver16/idx_sqlserver.migrations
@@ -1,8 +1,8 @@
-2122378240, I__create_procs.sql
--1324388010, 1.0__initial.sql
-287498538, 1.1.sql
+380683504, 1.0__initial.sql
+1291465909, 1.1.sql
-1431095657, 1.2__dropsFor_1.1.sql
--2048567958, 1.3.sql
--410961452, 1.4__dropsFor_1.3.sql
+1335479744, 1.3.sql
+-628940135, 1.4__dropsFor_1.3.sql
1607822082, R__order_views_mssql.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.0__initial.sql
index caf403e9b..e241e2ea6 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.0__initial.sql
@@ -170,6 +170,7 @@ create table [table] (
[to] nvarchar(255),
[varchar] nvarchar(255),
[foreign] nvarchar(255),
+ textfield nvarchar(255) not null,
constraint pk_table primary key ([index])
);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.1.sql
index e576e3db3..55dab5ea4 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.1.sql
@@ -67,7 +67,9 @@ update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
-- history migration goes here
-- alter table [table] set (system_versioning = on (history_table=dbo.table_history));
-- apply alter tables
+alter table [table] alter column textfield nvarchar(255);
alter table [table] add [select] nvarchar(255);
+alter table [table] add textfield2 nvarchar(255);
alter table migtest_ckey_detail add one_key integer;
alter table migtest_ckey_detail add two_key nvarchar(127);
alter table migtest_ckey_parent add assoc_id integer;
@@ -144,3 +146,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
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_table_textfield2 on [table] (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.3.sql
index 055b0d489..860097c2e 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.3.sql
@@ -21,6 +21,7 @@ IF OBJECT_ID('uq_migtest_e_basic_indextest5', 'UQ') IS NOT NULL alter table migt
IF OBJECT_ID('ck_migtest_e_enum_test_status', 'C') IS NOT NULL alter table migtest_e_enum drop constraint ck_migtest_e_enum_test_status;
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest3') drop index ix_migtest_e_basic_indextest3 ON migtest_e_basic;
IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('migtest_e_basic','U') AND name = 'ix_migtest_e_basic_indextest6') drop index ix_migtest_e_basic_indextest6 ON migtest_e_basic;
+IF EXISTS (SELECT name FROM sys.indexes WHERE object_id = OBJECT_ID('"table"','U') AND name = 'ix_table_textfield2') drop index ix_table_textfield2 ON "table";
-- apply changes
create table [migtest_QuOtEd] (
id nvarchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.4__dropsFor_1.3.sql
index 00b08667c..feeefad50 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/1.4__dropsFor_1.3.sql
@@ -10,7 +10,12 @@ alter table migtest_e_history drop period for system_time;
-- alter table migtest_e_history5 set (system_versioning = off (history_table=dbo.migtest_e_history5_history));
-- history migration goes here
-- alter table migtest_e_history5 set (system_versioning = on (history_table=dbo.migtest_e_history5_history));
+-- alter table [table] set (system_versioning = off (history_table=dbo.table_history));
+-- history migration goes here
+-- alter table [table] set (system_versioning = on (history_table=dbo.table_history));
-- apply alter tables
+EXEC usp_ebean_drop_column "table", textfield;
+EXEC usp_ebean_drop_column "table", textfield2;
EXEC usp_ebean_drop_column migtest_ckey_detail, one_key;
EXEC usp_ebean_drop_column migtest_ckey_detail, two_key;
EXEC usp_ebean_drop_column migtest_ckey_parent, assoc_id;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/idx_sqlserver.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/idx_sqlserver.migrations
index 019d940a0..b5e6f2407 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/idx_sqlserver.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/sqlserver17/idx_sqlserver.migrations
@@ -1,8 +1,8 @@
-2122378240, I__create_procs.sql
-2004279493, 1.0__initial.sql
-1649898025, 1.1.sql
+542129917, 1.0__initial.sql
+837691787, 1.1.sql
-1431095657, 1.2__dropsFor_1.1.sql
-294205466, 1.3.sql
--410961452, 1.4__dropsFor_1.3.sql
+-545642423, 1.3.sql
+-628940135, 1.4__dropsFor_1.3.sql
1607822082, R__order_views_mssql.sql
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.0__initial.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.0__initial.sql
index 91c6c6fc5..c39acd1ae 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.0__initial.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.0__initial.sql
@@ -156,6 +156,7 @@ create table "table" (
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255) not null,
constraint uq_table_to unique ("to"),
constraint uq_table_varchar unique ("varchar"),
constraint pk_table primary key ("index")
@@ -348,6 +349,7 @@ create table table_history(
"to" varchar(255),
"varchar" varchar(255),
"foreign" varchar(255),
+ textfield varchar(255),
sys_period tstzrange
);
create view table_with_history as select * from "table" union all select * from table_history;
@@ -359,11 +361,11 @@ begin
lowerTs = lower(OLD.sys_period);
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
if (TG_OP = 'UPDATE') then
- insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign");
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign", textfield) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign", OLD.textfield);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
- insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign");
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "foreign", textfield) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."foreign", OLD.textfield);
return old;
end if;
end;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.1.sql
index 7d50265ea..8e13c0a20 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.1.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.1.sql
@@ -70,7 +70,9 @@ drop function if exists table_history_version();
drop view table_with_history;
-- apply alter tables
+alter table "table" alter column textfield drop not null;
alter table "table" add column "select" varchar(255);
+alter table "table" add column textfield2 varchar(255);
alter table migtest_ckey_detail add column one_key integer;
alter table migtest_ckey_detail add column two_key varchar(127);
alter table migtest_ckey_parent add column assoc_id integer;
@@ -107,7 +109,9 @@ alter table migtest_e_history6 alter column test_number2 drop not null;
alter table migtest_e_history6_history alter column test_number2 drop not null;
alter table migtest_e_softdelete add column deleted boolean default false not null;
alter table migtest_oto_child add column master_id bigint;
+alter table table_history alter column textfield drop not null;
alter table table_history add column "select" varchar(255);
+alter table table_history add column textfield2 varchar(255);
-- apply post alter
alter table migtest_e_basic add constraint ck_migtest_e_basic_status check ( status in ('N','A','I','?'));
alter table migtest_e_basic add constraint uq_migtest_e_basic_description unique (description);
@@ -274,11 +278,11 @@ begin
lowerTs = lower(OLD.sys_period);
upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
if (TG_OP = 'UPDATE') then
- insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign", textfield, textfield2) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign", OLD.textfield, OLD.textfield2);
NEW.sys_period = tstzrange(upperTs,null);
return new;
elsif (TG_OP = 'DELETE') then
- insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign", textfield, textfield2) values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign", OLD.textfield, OLD.textfield2);
return old;
end if;
end;
@@ -318,3 +322,4 @@ alter table migtest_oto_child add constraint fk_migtest_oto_child_master_id fore
create index if not exists ix_migtest_e_basic_indextest3 on migtest_e_basic (indextest3);
create index if not exists ix_migtest_e_basic_indextest6 on migtest_e_basic (indextest6);
+create index if not exists ix_table_textfield2 on "table" (textfield2);
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.3.sql
index 4b04c0cbb..8665eb808 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.3.sql
@@ -16,6 +16,7 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest5;
alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status;
drop index if exists ix_migtest_e_basic_indextest3;
drop index if exists ix_migtest_e_basic_indextest6;
+drop index if exists ix_table_textfield2;
-- apply changes
create table "migtest_QuOtEd" (
id varchar(255) not null,
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.4__dropsFor_1.3.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.4__dropsFor_1.3.sql
index 822e9f61a..abf1cd14d 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.4__dropsFor_1.3.sql
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/1.4__dropsFor_1.3.sql
@@ -15,7 +15,13 @@ drop trigger if exists migtest_e_history5_history_upd on migtest_e_history5 casc
drop function if exists migtest_e_history5_history_version();
drop view migtest_e_history5_with_history;
+drop trigger if exists table_history_upd on "table" cascade;
+drop function if exists table_history_version();
+
+drop view table_with_history;
-- apply alter tables
+alter table "table" drop column textfield;
+alter table "table" drop column textfield2;
alter table migtest_ckey_detail drop column one_key;
alter table migtest_ckey_detail drop column two_key;
alter table migtest_ckey_parent drop column assoc_id;
@@ -35,6 +41,8 @@ alter table migtest_e_history5 drop column test_boolean;
alter table migtest_e_history5_history drop column test_boolean;
alter table migtest_e_softdelete drop column deleted;
alter table migtest_oto_child drop column master_id;
+alter table table_history drop column textfield;
+alter table table_history drop column textfield2;
-- apply post alter
create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history;
create or replace function migtest_e_history2_history_version() returns trigger as $$
@@ -82,6 +90,29 @@ create trigger migtest_e_history5_history_upd
before update or delete on migtest_e_history5
for each row execute procedure migtest_e_history5_history_version();
+create view table_with_history as select * from "table" union all select * from table_history;
+create or replace function table_history_version() returns trigger as $$
+declare
+ lowerTs timestamptz;
+ upperTs timestamptz;
+begin
+ lowerTs = lower(OLD.sys_period);
+ upperTs = greatest(lowerTs + '1 microsecond',current_timestamp);
+ if (TG_OP = 'UPDATE') then
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+ NEW.sys_period = tstzrange(upperTs,null);
+ return new;
+ elsif (TG_OP = 'DELETE') then
+ insert into table_history (sys_period,"index", "from", "to", "varchar", "select", "foreign") values (tstzrange(lowerTs,upperTs), OLD."index", OLD."from", OLD."to", OLD."varchar", OLD."select", OLD."foreign");
+ return old;
+ end if;
+end;
+$$ LANGUAGE plpgsql;
+
+create trigger table_history_upd
+ before update or delete on "table"
+ for each row execute procedure table_history_version();
+
drop table if exists migtest_e_user cascade;
drop sequence if exists migtest_e_user_seq;
drop table if exists migtest_mtm_c_migtest_mtm_m cascade;
diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/idx_yugabyte.migrations b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/idx_yugabyte.migrations
index 0781d38af..dd232e9a8 100644
--- a/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/idx_yugabyte.migrations
+++ b/ebean-test/src/test/resources/migrationtest/dbmigration/yugabyte/idx_yugabyte.migrations
@@ -1,7 +1,7 @@
-1497343697, 1.0__initial.sql
--870102763, 1.1.sql
+-1409672039, 1.0__initial.sql
+380200367, 1.1.sql
-261111052, 1.2__dropsFor_1.1.sql
--158984239, 1.3.sql
-1729345905, 1.4__dropsFor_1.3.sql
+-2084806674, 1.3.sql
+-709144111, 1.4__dropsFor_1.3.sql
561281075, R__order_views.sql