Skip to content

Commit 3c74824

Browse files
committed
just delete all rows
Signed-off-by: jamal-khey <[email protected]>
1 parent b88c8c2 commit 3c74824

File tree

3 files changed

+16
-35
lines changed

3 files changed

+16
-35
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
2+
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-latest.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
3+
<changeSet author="jamalk (generated)" id="1734002324759-1">
4+
<sqlFile path="migrate_limit_reduction_data_reset-all.sql"
5+
relativeToChangelogFile="true"
6+
encoding="UTF-8"/>
7+
</changeSet>
8+
</databaseChangeLog>
Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,5 @@
1-
-- BEGIN;
1+
-- First truncate the child table
2+
TRUNCATE TABLE limit_reduction_entity_reductions;
23

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;
4+
-- Then truncate the parent table
5+
TRUNCATE TABLE limit_reduction_entity CASCADE;

src/main/resources/db/changelog/db.changelog-master.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ databaseChangeLog:
3636
- include:
3737
file: changesets/changelog_20240705T122208Z.xml
3838
relativeToChangelogFile: true
39+
- include:
40+
file: changesets/changelog_20241212T111835Z.xml
41+
relativeToChangelogFile: true
42+

0 commit comments

Comments
 (0)