From 10c01574d2f0f55d914d259c77179c38be2582e8 Mon Sep 17 00:00:00 2001 From: Roland Praml Date: Mon, 14 Mar 2022 13:12:24 +0100 Subject: [PATCH] H2: No effective change Statements reordered --- .../dbmigration/h2/1.0__initial.sql | 11 +++-- .../migrationtest/dbmigration/h2/1.1.sql | 44 +++++++------------ .../dbmigration/h2/1.2__dropsFor_1.1.sql | 14 +++--- .../migrationtest/dbmigration/h2/1.3.sql | 32 +++++--------- .../dbmigration/h2/1.4__dropsFor_1.3.sql | 23 ++++------ .../dbmigration/h2/idx_h2.migrations | 10 ++--- 6 files changed, 53 insertions(+), 81 deletions(-) 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 c2e7c9fea..70abeb07f 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 @@ -183,6 +183,7 @@ create table migtest_e_history2_history( sys_period_end timestamp ); 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.config.dbplatform.h2.H2HistoryTrigger"; create table migtest_e_history3_history( id integer, @@ -191,6 +192,7 @@ create table migtest_e_history3_history( sys_period_end timestamp ); create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history; +create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; create table migtest_e_history4_history( id integer, @@ -199,6 +201,7 @@ create table migtest_e_history4_history( sys_period_end timestamp ); create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history; +create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; create table migtest_e_history5_history( id integer, @@ -207,6 +210,7 @@ create table migtest_e_history5_history( sys_period_end timestamp ); 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.config.dbplatform.h2.H2HistoryTrigger"; create table migtest_e_history6_history( id integer, @@ -216,6 +220,7 @@ create table migtest_e_history6_history( sys_period_end timestamp ); create view migtest_e_history6_with_history as select * from migtest_e_history6 union all select * from migtest_e_history6_history; +create trigger migtest_e_history6_history_upd before update,delete on migtest_e_history6 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; -- foreign keys and indices create index ix_migtest_fk_cascade_one_id on migtest_fk_cascade (one_id); @@ -229,9 +234,3 @@ alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign ke create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); --- apply history trigger -create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; -create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; -create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; -create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; -create trigger migtest_e_history6_history_upd before update,delete on migtest_e_history6 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; 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 860ca30d5..de2cdb548 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 @@ -9,10 +9,6 @@ alter table migtest_e_basic drop constraint uq_migtest_e_basic_indextest6; alter table migtest_e_enum drop constraint if exists ck_migtest_e_enum_test_status; drop index if exists ix_migtest_e_basic_indextest1; drop index if exists ix_migtest_e_basic_indextest5; -drop view if exists migtest_e_history2_with_history; -drop view if exists migtest_e_history3_with_history; -drop view if exists migtest_e_history4_with_history; -drop view if exists migtest_e_history5_with_history; -- apply changes create table migtest_e_user ( id integer generated by default as identity not null, @@ -45,6 +41,14 @@ insert into migtest_e_user (id) select distinct user_id from migtest_e_basic; -- NOTE: table has @History - special migration may be necessary update migtest_e_history2 set test_string = 'unknown' where test_string is null; +drop trigger migtest_e_history2_history_upd; +drop view migtest_e_history2_with_history; +drop trigger migtest_e_history3_history_upd; +drop view migtest_e_history3_with_history; +drop trigger migtest_e_history4_history_upd; +drop view migtest_e_history4_with_history; +drop trigger migtest_e_history5_history_upd; +drop view migtest_e_history5_with_history; -- NOTE: table has @History - special migration may be necessary update migtest_e_history6 set test_number1 = 42 where test_number1 is null; @@ -101,9 +105,18 @@ create table migtest_e_history_history( sys_period_end timestamp ); create view migtest_e_history_with_history as select * from migtest_e_history union all select * from migtest_e_history_history; +create trigger migtest_e_history_history_upd before update,delete on migtest_e_history for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; comment on column migtest_e_history.test_string is 'Column altered to long now'; comment on table migtest_e_history is 'We have history now'; +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.config.dbplatform.h2.H2HistoryTrigger"; +create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history; +create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history; +create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.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.config.dbplatform.h2.H2HistoryTrigger"; -- foreign keys and indices create index ix_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c on migtest_mtm_c_migtest_mtm_m (migtest_mtm_c_id); alter table migtest_mtm_c_migtest_mtm_m add constraint fk_migtest_mtm_c_migtest_mtm_m_migtest_mtm_c foreign key (migtest_mtm_c_id) references migtest_mtm_c (id) on delete restrict on update restrict; @@ -133,26 +146,3 @@ 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); --- apply history view -create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; - -create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history; - -create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history; - -create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history; - --- apply history trigger -create trigger migtest_e_history_history_upd before update,delete on migtest_e_history for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; --- changes: [add test_string2, add test_string3, add new_column] -drop trigger migtest_e_history2_history_upd; -create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; --- changes: [exclude test_string] -drop trigger migtest_e_history3_history_upd; -create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; --- changes: [alter test_number] -drop trigger migtest_e_history4_history_upd; -create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; --- changes: [add test_boolean] -drop trigger migtest_e_history5_history_upd; -create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; diff --git a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.2__dropsFor_1.1.sql b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.2__dropsFor_1.1.sql index 1d3691cc8..f3112c454 100644 --- a/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.2__dropsFor_1.1.sql +++ b/ebean-test/src/test/resources/migrationtest/dbmigration/h2/1.2__dropsFor_1.1.sql @@ -1,6 +1,7 @@ -- Migrationscripts for ebean unittest --- drop dependencies -drop view if exists migtest_e_history2_with_history; +-- apply changes +drop trigger migtest_e_history2_history_upd; +drop view migtest_e_history2_with_history; -- apply alter tables alter table migtest_e_basic drop column description_file; alter table migtest_e_basic drop column old_boolean; @@ -11,12 +12,7 @@ alter table migtest_e_history2 drop column obsolete_string2; alter table migtest_e_history2_history drop column obsolete_string1; alter table migtest_e_history2_history drop column obsolete_string2; -- 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.config.dbplatform.h2.H2HistoryTrigger"; drop table if exists migtest_e_ref; drop sequence if exists migtest_e_ref_seq; --- apply history view -create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; - --- apply history trigger --- changes: [drop obsolete_string1, drop obsolete_string2] -drop trigger migtest_e_history2_history_upd; -create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; 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 d7e856699..0a8be48a4 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,9 +16,6 @@ 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 view if exists migtest_e_history2_with_history; -drop view if exists migtest_e_history3_with_history; -drop view if exists migtest_e_history4_with_history; -- apply changes create table migtest_e_ref ( id integer generated by default as identity not null, @@ -31,6 +28,12 @@ create table migtest_e_ref ( update migtest_e_basic set status2 = 'N' where status2 is null; update migtest_e_basic set user_id = 23 where user_id is null; +drop trigger migtest_e_history2_history_upd; +drop view migtest_e_history2_with_history; +drop trigger migtest_e_history3_history_upd; +drop view migtest_e_history3_with_history; +drop trigger migtest_e_history4_history_upd; +drop view migtest_e_history4_with_history; -- NOTE: table has @History - special migration may be necessary update migtest_e_history6 set test_number2 = 7 where test_number2 is null; @@ -66,6 +69,12 @@ alter table migtest_e_basic add constraint uq_migtest_e_basic_indextest6 unique alter table migtest_e_enum add constraint ck_migtest_e_enum_test_status check ( test_status in ('N','A','I')); comment on column migtest_e_history.test_string is ''; comment on table migtest_e_history is ''; +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.config.dbplatform.h2.H2HistoryTrigger"; +create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history; +create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; +create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history; +create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; -- foreign keys and indices alter table migtest_fk_cascade add constraint fk_migtest_fk_cascade_one_id foreign key (one_id) references migtest_fk_cascade_one (id) on delete cascade on update restrict; alter table migtest_fk_set_null add constraint fk_migtest_fk_set_null_one_id foreign key (one_id) references migtest_fk_one (id) on delete set null on update restrict; @@ -74,20 +83,3 @@ alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign ke create index ix_migtest_e_basic_indextest1 on migtest_e_basic (indextest1); create index ix_migtest_e_basic_indextest5 on migtest_e_basic (indextest5); --- apply history view -create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; - -create view migtest_e_history3_with_history as select * from migtest_e_history3 union all select * from migtest_e_history3_history; - -create view migtest_e_history4_with_history as select * from migtest_e_history4 union all select * from migtest_e_history4_history; - --- apply history trigger --- changes: [add obsolete_string1, add obsolete_string2] -drop trigger migtest_e_history2_history_upd; -create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; --- changes: [include test_string] -drop trigger migtest_e_history3_history_upd; -create trigger migtest_e_history3_history_upd before update,delete on migtest_e_history3 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; --- changes: [alter test_number] -drop trigger migtest_e_history4_history_upd; -create trigger migtest_e_history4_history_upd before update,delete on migtest_e_history4 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; 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 d6ce59146..50e6ed546 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 @@ -4,8 +4,11 @@ drop trigger migtest_e_history_history_upd; drop view migtest_e_history_with_history; drop table migtest_e_history_history; -drop view if exists migtest_e_history2_with_history; -drop view if exists migtest_e_history5_with_history; +-- apply changes +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; -- apply alter tables alter table migtest_ckey_detail drop column one_key; alter table migtest_ckey_detail drop column two_key; @@ -28,20 +31,12 @@ 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; -- 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.config.dbplatform.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.config.dbplatform.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; drop table if exists migtest_mtm_m_migtest_mtm_c; drop table if exists migtest_mtm_m_phone_numbers; --- apply history view -create view migtest_e_history2_with_history as select * from migtest_e_history2 union all select * from migtest_e_history2_history; - -create view migtest_e_history5_with_history as select * from migtest_e_history5 union all select * from migtest_e_history5_history; - --- apply history trigger --- changes: [drop test_string2, drop test_string3, drop new_column] -drop trigger migtest_e_history2_history_upd; -create trigger migtest_e_history2_history_upd before update,delete on migtest_e_history2 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; --- changes: [drop test_boolean] -drop trigger migtest_e_history5_history_upd; -create trigger migtest_e_history5_history_upd before update,delete on migtest_e_history5 for each row call "io.ebean.config.dbplatform.h2.H2HistoryTrigger"; 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 a9f4a8b34..049ac027a 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 @@ --698689813, 1.0__initial.sql -2028346373, 1.1.sql --2063980912, 1.2__dropsFor_1.1.sql --508824171, 1.3.sql -511468518, 1.4__dropsFor_1.3.sql +1200492722, 1.0__initial.sql +374062636, 1.1.sql +-1366392410, 1.2__dropsFor_1.1.sql +1367061136, 1.3.sql +-1382108238, 1.4__dropsFor_1.3.sql 783227075, R__multi_comments.sql 561281075, R__order_views.sql