Skip to content

Commit b88c8c2

Browse files
committed
migration script seems to work
Signed-off-by: jamal-khey <[email protected]>
1 parent d7b4361 commit b88c8c2

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
-- BEGIN;
2+
3+
-- part 1 - delete element from List<LimitReductionEntity> limitReductions;
4+
DELETE
5+
FROM limit_reduction_entity_reductions
6+
WHERE index >= 5;
7+
8+
9+
-- part 2 - add element into LimitReductionEntity
10+
UPDATE limit_reduction_entity_reductions
11+
SET reductions = 1.0
12+
WHERE index < 6;
13+
14+
-- Insert missing values up to 6 elements
15+
INSERT INTO limit_reduction_entity_reductions (limit_reduction_entity_id, index, reductions)
16+
SELECT
17+
lre.id,
18+
numbers.index,
19+
1.0
20+
FROM limit_reduction_entity lre
21+
CROSS JOIN (
22+
SELECT 0 as index UNION ALL
23+
SELECT 1 UNION ALL
24+
SELECT 2 UNION ALL
25+
SELECT 3 UNION ALL
26+
SELECT 4 UNION ALL
27+
SELECT 5
28+
) numbers
29+
WHERE NOT EXISTS (
30+
SELECT 1
31+
FROM limit_reduction_entity_reductions lr
32+
WHERE lr.limit_reduction_entity_id = lre.id
33+
AND lr.index = numbers.index
34+
);
35+
36+
-- ROLLBACK;

0 commit comments

Comments
 (0)