From d7b436103aba6dbe777a5d4fb2001b61e4045ba6 Mon Sep 17 00:00:00 2001 From: jamal-khey Date: Tue, 10 Dec 2024 16:47:49 +0100 Subject: [PATCH 1/7] add new ranges Signed-off-by: jamal-khey --- src/main/resources/config/application.yaml | 29 +++++++++++++--------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/main/resources/config/application.yaml b/src/main/resources/config/application.yaml index 94e6263b..3b8aa66d 100644 --- a/src/main/resources/config/application.yaml +++ b/src/main/resources/config/application.yaml @@ -59,9 +59,7 @@ security-analysis: highBound: 75 - nominalV: 90 lowBound: 75 - highBound: 120 - - nominalV: 150 - lowBound: 120 + # FIXME: is highbound correct ? highBound: 180 - nominalV: 225 lowBound: 180 @@ -70,23 +68,30 @@ security-analysis: lowBound: 300 highBound: 500 limitDurations: - - lowBound: 600 + - lowBound: 1200 lowClosed: false highBound: ~ highClosed: false + - lowBound: 600 + lowClosed: false + highBound: 1200 + highClosed: false - lowBound: 300 lowClosed: true highBound: 600 highClosed: true - - lowBound: 0 + - lowBound: 60 lowClosed: true highBound: 300 highClosed: false + - lowBound: 0 + lowClosed: true + highBound: 60 + highClosed: false defaultValues: - - [ 1, 1, 1, 1 ] - - [ 1, 1, 1, 1 ] - - [ 1, 1, 1, 1 ] - - [ 1, 1, 1, 1 ] - - [ 1, 1, 1, 1 ] - - [ 1, 1, 1, 1 ] - - [ 1, 1, 1, 1 ] \ No newline at end of file + - [ 1, 1, 1, 1, 1, 1 ] + - [ 1, 1, 1, 1, 1, 1 ] + - [ 1, 1, 1, 1, 1, 1 ] + - [ 1, 1, 1, 1, 1, 1 ] + - [ 1, 1, 1, 1, 1, 1 ] + - [ 1, 1, 1, 1, 1, 1 ] \ No newline at end of file From b88c8c2c810f3e6df966b3e060532e8a349bb912 Mon Sep 17 00:00:00 2001 From: jamal-khey Date: Thu, 12 Dec 2024 13:39:12 +0100 Subject: [PATCH 2/7] migration script seems to work Signed-off-by: jamal-khey --- ...migrate_limit_reduction_data_reset-all.sql | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/main/resources/db/changelog/changesets/migrate_limit_reduction_data_reset-all.sql diff --git a/src/main/resources/db/changelog/changesets/migrate_limit_reduction_data_reset-all.sql b/src/main/resources/db/changelog/changesets/migrate_limit_reduction_data_reset-all.sql new file mode 100644 index 00000000..0be25867 --- /dev/null +++ b/src/main/resources/db/changelog/changesets/migrate_limit_reduction_data_reset-all.sql @@ -0,0 +1,36 @@ +-- BEGIN; + +-- part 1 - delete element from List limitReductions; +DELETE +FROM limit_reduction_entity_reductions +WHERE index >= 5; + + +-- part 2 - add element into LimitReductionEntity +UPDATE limit_reduction_entity_reductions +SET reductions = 1.0 +WHERE index < 6; + +-- Insert missing values up to 6 elements +INSERT INTO limit_reduction_entity_reductions (limit_reduction_entity_id, index, reductions) +SELECT + lre.id, + numbers.index, + 1.0 +FROM limit_reduction_entity lre + CROSS JOIN ( + SELECT 0 as index UNION ALL + SELECT 1 UNION ALL + SELECT 2 UNION ALL + SELECT 3 UNION ALL + SELECT 4 UNION ALL + SELECT 5 +) numbers +WHERE NOT EXISTS ( + SELECT 1 + FROM limit_reduction_entity_reductions lr + WHERE lr.limit_reduction_entity_id = lre.id + AND lr.index = numbers.index +); + +-- ROLLBACK; \ No newline at end of file From 3c74824b0fc976a257cc4defd73f54c7fa980971 Mon Sep 17 00:00:00 2001 From: jamal-khey Date: Thu, 12 Dec 2024 20:00:05 +0100 Subject: [PATCH 3/7] just delete all rows Signed-off-by: jamal-khey --- .../changesets/changelog_20241212T111835Z.xml | 8 ++++ ...migrate_limit_reduction_data_reset-all.sql | 39 ++----------------- .../db/changelog/db.changelog-master.yaml | 4 ++ 3 files changed, 16 insertions(+), 35 deletions(-) create mode 100644 src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml diff --git a/src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml b/src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml new file mode 100644 index 00000000..aee884f9 --- /dev/null +++ b/src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml @@ -0,0 +1,8 @@ + + + + + + diff --git a/src/main/resources/db/changelog/changesets/migrate_limit_reduction_data_reset-all.sql b/src/main/resources/db/changelog/changesets/migrate_limit_reduction_data_reset-all.sql index 0be25867..8695ff2e 100644 --- a/src/main/resources/db/changelog/changesets/migrate_limit_reduction_data_reset-all.sql +++ b/src/main/resources/db/changelog/changesets/migrate_limit_reduction_data_reset-all.sql @@ -1,36 +1,5 @@ --- BEGIN; +-- First truncate the child table +TRUNCATE TABLE limit_reduction_entity_reductions; --- part 1 - delete element from List limitReductions; -DELETE -FROM limit_reduction_entity_reductions -WHERE index >= 5; - - --- part 2 - add element into LimitReductionEntity -UPDATE limit_reduction_entity_reductions -SET reductions = 1.0 -WHERE index < 6; - --- Insert missing values up to 6 elements -INSERT INTO limit_reduction_entity_reductions (limit_reduction_entity_id, index, reductions) -SELECT - lre.id, - numbers.index, - 1.0 -FROM limit_reduction_entity lre - CROSS JOIN ( - SELECT 0 as index UNION ALL - SELECT 1 UNION ALL - SELECT 2 UNION ALL - SELECT 3 UNION ALL - SELECT 4 UNION ALL - SELECT 5 -) numbers -WHERE NOT EXISTS ( - SELECT 1 - FROM limit_reduction_entity_reductions lr - WHERE lr.limit_reduction_entity_id = lre.id - AND lr.index = numbers.index -); - --- ROLLBACK; \ No newline at end of file +-- Then truncate the parent table +TRUNCATE TABLE limit_reduction_entity CASCADE; \ No newline at end of file diff --git a/src/main/resources/db/changelog/db.changelog-master.yaml b/src/main/resources/db/changelog/db.changelog-master.yaml index bfcbcc95..3d8814b5 100644 --- a/src/main/resources/db/changelog/db.changelog-master.yaml +++ b/src/main/resources/db/changelog/db.changelog-master.yaml @@ -36,3 +36,7 @@ databaseChangeLog: - include: file: changesets/changelog_20240705T122208Z.xml relativeToChangelogFile: true + - include: + file: changesets/changelog_20241212T111835Z.xml + relativeToChangelogFile: true + From 174998d69960f55d4538a97733aa697a8a7a6356 Mon Sep 17 00:00:00 2001 From: jamal-khey Date: Fri, 13 Dec 2024 09:17:48 +0100 Subject: [PATCH 4/7] just delete all rows Signed-off-by: jamal-khey --- .../db/changelog/changesets/changelog_20241212T111835Z.xml | 2 +- ...tion_data_reset-all.sql => migrate_limit_reduction_rest.sql} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/main/resources/db/changelog/changesets/{migrate_limit_reduction_data_reset-all.sql => migrate_limit_reduction_rest.sql} (100%) diff --git a/src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml b/src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml index aee884f9..ae650eac 100644 --- a/src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml +++ b/src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml @@ -1,7 +1,7 @@ - diff --git a/src/main/resources/db/changelog/changesets/migrate_limit_reduction_data_reset-all.sql b/src/main/resources/db/changelog/changesets/migrate_limit_reduction_rest.sql similarity index 100% rename from src/main/resources/db/changelog/changesets/migrate_limit_reduction_data_reset-all.sql rename to src/main/resources/db/changelog/changesets/migrate_limit_reduction_rest.sql From 5006974c9c4f6ee83fcfe0126a13278331f0938a Mon Sep 17 00:00:00 2001 From: jamal-khey Date: Fri, 13 Dec 2024 09:28:04 +0100 Subject: [PATCH 5/7] only migrate postgres data Signed-off-by: jamal-khey --- .../changesets/changelog_20241212T111835Z.xml | 10 +++++++--- .../changesets/migrate_limit_reduction_rest.sql | 3 +-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml b/src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml index ae650eac..e3b3ac6f 100644 --- a/src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml +++ b/src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml @@ -1,8 +1,12 @@ - + diff --git a/src/main/resources/db/changelog/changesets/migrate_limit_reduction_rest.sql b/src/main/resources/db/changelog/changesets/migrate_limit_reduction_rest.sql index 8695ff2e..b5c26473 100644 --- a/src/main/resources/db/changelog/changesets/migrate_limit_reduction_rest.sql +++ b/src/main/resources/db/changelog/changesets/migrate_limit_reduction_rest.sql @@ -1,5 +1,4 @@ --- First truncate the child table + TRUNCATE TABLE limit_reduction_entity_reductions; --- Then truncate the parent table TRUNCATE TABLE limit_reduction_entity CASCADE; \ No newline at end of file From e7278ac6e1fb40f47bd9bb23d9eebc10ada9e291 Mon Sep 17 00:00:00 2001 From: jamal-khey Date: Tue, 17 Dec 2024 10:44:23 +0100 Subject: [PATCH 6/7] fix review comments Signed-off-by: jamal-khey --- src/main/resources/config/application.yaml | 1 - .../changesets/changelog_20241212T111835Z.xml | 10 +++------- .../changesets/migrate_limit_reduction_rest.sql | 4 ---- 3 files changed, 3 insertions(+), 12 deletions(-) delete mode 100644 src/main/resources/db/changelog/changesets/migrate_limit_reduction_rest.sql diff --git a/src/main/resources/config/application.yaml b/src/main/resources/config/application.yaml index 3b8aa66d..f86a6904 100644 --- a/src/main/resources/config/application.yaml +++ b/src/main/resources/config/application.yaml @@ -59,7 +59,6 @@ security-analysis: highBound: 75 - nominalV: 90 lowBound: 75 - # FIXME: is highbound correct ? highBound: 180 - nominalV: 225 lowBound: 180 diff --git a/src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml b/src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml index e3b3ac6f..255bec30 100644 --- a/src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml +++ b/src/main/resources/db/changelog/changesets/changelog_20241212T111835Z.xml @@ -1,12 +1,8 @@ - + + TRUNCATE TABLE limit_reduction_entity CASCADE; + diff --git a/src/main/resources/db/changelog/changesets/migrate_limit_reduction_rest.sql b/src/main/resources/db/changelog/changesets/migrate_limit_reduction_rest.sql deleted file mode 100644 index b5c26473..00000000 --- a/src/main/resources/db/changelog/changesets/migrate_limit_reduction_rest.sql +++ /dev/null @@ -1,4 +0,0 @@ - -TRUNCATE TABLE limit_reduction_entity_reductions; - -TRUNCATE TABLE limit_reduction_entity CASCADE; \ No newline at end of file From 0dd116b0ce8bf1f2d2b073e7f1002094b045ed9b Mon Sep 17 00:00:00 2001 From: jamal-khey Date: Thu, 19 Dec 2024 14:14:41 +0100 Subject: [PATCH 7/7] fix closing bound Signed-off-by: jamal-khey --- src/main/resources/config/application.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/config/application.yaml b/src/main/resources/config/application.yaml index f86a6904..08a8cc42 100644 --- a/src/main/resources/config/application.yaml +++ b/src/main/resources/config/application.yaml @@ -68,17 +68,17 @@ security-analysis: highBound: 500 limitDurations: - lowBound: 1200 - lowClosed: false + lowClosed: true highBound: ~ highClosed: false - lowBound: 600 - lowClosed: false + lowClosed: true highBound: 1200 highClosed: false - lowBound: 300 lowClosed: true highBound: 600 - highClosed: true + highClosed: false - lowBound: 60 lowClosed: true highBound: 300