Skip to content

Commit cdbfc51

Browse files
Fix: Delete child records before parent in Pentaho removal migration
- Add changeset to delete m_role_permission entries first - Prevents FK constraint violation FK8DEDB048103B544B on MariaDB/MySQL - Maintains deletion order: role_permissions -> permissions -> reports - Fixes test-core-1 failures on MariaDB and MySQL - Tested locally: all 919 provider tests pass with MySQL
1 parent 9b9bcf2 commit cdbfc51

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed
Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!--
3-
43
Licensed to the Apache Software Foundation (ASF) under one
54
or more contributor license agreements. See the NOTICE file
65
distributed with this work for additional information
@@ -17,25 +16,44 @@
1716
KIND, either express or implied. See the License for the
1817
specific language governing permissions and limitations
1918
under the License.
20-
2119
-->
2220
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.1.xsd">
21+
22+
<!-- Step 1: Delete child records from m_role_permission first -->
2323
<changeSet author="fineract" id="1">
24+
<preConditions onFail="MARK_RAN">
25+
<sqlCheck expectedResult="1">
26+
SELECT COUNT(*) > 0
27+
FROM m_role_permission rp
28+
JOIN m_permission p ON p.id = rp.permission_id
29+
WHERE p.code LIKE '%Pentaho%'
30+
</sqlCheck>
31+
</preConditions>
32+
<comment>Remove role permissions referencing deprecated Pentaho report permissions</comment>
33+
<delete tableName="m_role_permission">
34+
<where>permission_id IN (SELECT id FROM m_permission WHERE code LIKE '%Pentaho%')</where>
35+
</delete>
36+
</changeSet>
37+
38+
<!-- Step 2: Delete parent records from m_permission -->
39+
<changeSet author="fineract" id="2">
2440
<preConditions onFail="MARK_RAN">
2541
<sqlCheck expectedResult="1">SELECT COUNT(*) > 0 FROM m_permission WHERE code LIKE '%Pentaho%'</sqlCheck>
2642
</preConditions>
2743
<comment>Remove deprecated Pentaho report permissions</comment>
28-
<sql>
29-
DELETE FROM m_permission WHERE code LIKE '%Pentaho%';
30-
</sql>
44+
<delete tableName="m_permission">
45+
<where>code LIKE '%Pentaho%'</where>
46+
</delete>
3147
</changeSet>
32-
<changeSet author="fineract" id="2">
48+
49+
<!-- Step 3: Delete Pentaho reports from stretchy_report -->
50+
<changeSet author="fineract" id="3">
3351
<preConditions onFail="MARK_RAN">
3452
<sqlCheck expectedResult="1">SELECT COUNT(*) > 0 FROM stretchy_report WHERE report_name LIKE '%Pentaho%'</sqlCheck>
3553
</preConditions>
3654
<comment>Remove deprecated Pentaho reports from stretchy_report table</comment>
37-
<sql>
38-
DELETE FROM stretchy_report WHERE report_name LIKE '%Pentaho%';
39-
</sql>
55+
<delete tableName="stretchy_report">
56+
<where>report_name LIKE '%Pentaho%'</where>
57+
</delete>
4058
</changeSet>
41-
</databaseChangeLog>
59+
</databaseChangeLog>

0 commit comments

Comments
 (0)