FIX: notNull -> null transition must be applied also to history

This commit is contained in:
Roland Praml
2022-03-14 14:13:10 +01:00
parent 5b8bb41598
commit 610a8b2df6
5 changed files with 34 additions and 38 deletions
@@ -757,7 +757,7 @@ public class BaseTableDdl implements TableDdl {
if (isTrue(alter.isWithHistory())) {
// we will apply only type changes or notNull -> null transition
boolean isNull = false; // TODO: Boolean.FALSE.equals(alter.isNotnull());
boolean isNull = Boolean.FALSE.equals(alter.isNotnull());
boolean applyToHistory = alter.getType() != null || isNull;
if (applyToHistory) {
platformDdl.regenerateHistoryTriggers(writer, alter.getTableName());
@@ -163,19 +163,7 @@ create column table migtest_oto_master (
);
-- apply alter tables
-- foreign keys and indices
-- explicit index "ix_migtest_fk_cascade_one_id" for single column "one_id" of table "migtest_fk_cascade" is not necessary;
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;
-- explicit index "ix_migtest_fk_set_null_one_id" for single column "one_id" of table "migtest_fk_set_null" is not necessary;
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;
-- explicit index "ix_migtest_e_basic_eref_id" for single column "eref_id" of table "migtest_e_basic" is not necessary;
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_e_basic_indextest1" for single column "indextest1" of table "migtest_e_basic" is not necessary;
-- explicit index "ix_migtest_e_basic_indextest5" for single column "indextest5" of table "migtest_e_basic" is not necessary;
-- apply history view
-- apply post alter
create column table migtest_e_history2_history (
id integer,
test_string nvarchar(255),
@@ -239,3 +227,15 @@ alter table migtest_e_history6 add (
);
alter table migtest_e_history6 add period for system_time(sys_period_start,sys_period_end);
alter table migtest_e_history6 add system versioning history table migtest_e_history6_history;
-- foreign keys and indices
-- explicit index "ix_migtest_fk_cascade_one_id" for single column "one_id" of table "migtest_fk_cascade" is not necessary;
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;
-- explicit index "ix_migtest_fk_set_null_one_id" for single column "one_id" of table "migtest_fk_set_null" is not necessary;
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;
-- explicit index "ix_migtest_e_basic_eref_id" for single column "eref_id" of table "migtest_e_basic" is not necessary;
alter table migtest_e_basic add constraint fk_migtest_e_basic_eref_id foreign key (eref_id) references migtest_e_ref (id) on delete restrict on update restrict;
-- explicit index "ix_migtest_e_basic_indextest1" for single column "indextest1" of table "migtest_e_basic" is not necessary;
-- explicit index "ix_migtest_e_basic_indextest5" for single column "indextest5" of table "migtest_e_basic" is not necessary;
@@ -80,17 +80,17 @@ update migtest_e_basic set status = 'A' where status is null;
-- rename all collisions;
insert into migtest_e_user (id) select distinct user_id from migtest_e_basic;
alter table migtest_e_history2 drop system versioning;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history2 set test_string = 'unknown' where test_string is null;
alter table migtest_e_history2 drop system versioning;
alter table migtest_e_history3 drop system versioning;
alter table migtest_e_history4 drop system versioning;
alter table migtest_e_history5 drop system versioning;
alter table migtest_e_history6 drop system versioning;
-- NOTE: table has @History - special migration may be necessary
update migtest_e_history6 set test_number1 = 42 where test_number1 is null;
alter table migtest_e_history6 drop system versioning;
-- apply alter tables
alter table migtest_ckey_detail add (one_key integer,
two_key nvarchar(127));
@@ -108,7 +108,6 @@ alter table migtest_e_history2 alter (test_string nvarchar(255) default 'unknown
alter table migtest_e_history2 add (test_string2 nvarchar(255),
test_string3 nvarchar(255) default 'unknown' not null,
new_column nvarchar(20));
alter table migtest_e_history2_history alter (test_string nvarchar(255) default 'unknown' not null);
alter table migtest_e_history2_history add (test_string2 nvarchar(255),
test_string3 nvarchar(255) default 'unknown',
new_column nvarchar(20));
@@ -118,8 +117,7 @@ alter table migtest_e_history5 add (test_boolean boolean default false not null)
alter table migtest_e_history5_history add (test_boolean boolean default false);
alter table migtest_e_history6 alter (test_number1 integer default 42 not null,
test_number2 integer);
alter table migtest_e_history6_history alter (test_number1 integer default 42 not null,
test_number2 integer);
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);
-- apply post alter
@@ -133,6 +131,18 @@ alter table migtest_e_basic add constraint ck_migtest_e_basic_progress check ( p
-- cannot create unique index "uq_migtest_e_basic_name" on table "migtest_e_basic" with nullable columns;
-- cannot create unique index "uq_migtest_e_basic_indextest4" on table "migtest_e_basic" with nullable columns;
-- cannot create unique index "uq_migtest_e_basic_indextest5" on table "migtest_e_basic" with nullable columns;
create column table migtest_e_history_history (
id integer,
test_string bigint,
sys_period_start timestamp,
sys_period_end timestamp
);
alter table migtest_e_history add (
sys_period_start TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW START,
sys_period_end TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW END
);
alter table migtest_e_history add period for system_time(sys_period_start,sys_period_end);
alter table migtest_e_history add system versioning history table migtest_e_history_history;
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';
alter table migtest_e_history2 add system versioning history table migtest_e_history2_history not validated;
@@ -169,16 +179,3 @@ 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;
-- apply history view
create column table migtest_e_history_history (
id integer,
test_string bigint,
sys_period_start timestamp,
sys_period_end timestamp
);
alter table migtest_e_history add (
sys_period_start TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW START,
sys_period_end TIMESTAMP NOT NULL GENERATED ALWAYS AS ROW END
);
alter table migtest_e_history add period for system_time(sys_period_start,sys_period_end);
alter table migtest_e_history add system versioning history table migtest_e_history_history;
@@ -107,7 +107,7 @@ alter table migtest_e_basic add (description_file blob,
alter table migtest_e_history2 alter (test_string nvarchar(255) default null);
alter table migtest_e_history2 add (obsolete_string1 nvarchar(255),
obsolete_string2 nvarchar(255));
alter table migtest_e_history2_history alter (test_string nvarchar(255) default null);
alter table migtest_e_history2_history alter (test_string nvarchar(255));
alter table migtest_e_history2_history add (obsolete_string1 nvarchar(255),
obsolete_string2 nvarchar(255));
alter table migtest_e_history4 alter (test_number decimal);
@@ -116,8 +116,7 @@ alter table migtest_e_history4_history alter (test_number decimal);
alter table migtest_e_history4_history alter (test_number integer);
alter table migtest_e_history6 alter (test_number1 integer default null,
test_number2 integer default 7 not null);
alter table migtest_e_history6_history alter (test_number1 integer default null,
test_number2 integer default 7 not null);
alter table migtest_e_history6_history alter (test_number1 integer);
-- 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 ck_migtest_e_basic_status2 check ( status2 in ('N','A','I'));
@@ -1,8 +1,8 @@
-745347271, I__create_procs.sql
1671978053, 1.0__initial.sql
945235204, 1.1.sql
881849401, 1.0__initial.sql
-1990555725, 1.1.sql
197547825, 1.2__dropsFor_1.1.sql
1030116997, 1.3.sql
1338960395, 1.3.sql
1812245353, 1.4__dropsFor_1.3.sql
1906063401, R__order_views_hana.sql