Skip to content

Commit 53269ba

Browse files
authored
Merge pull request #5789
FINERACT-2455: WC - Re-name delinquency and breach configuration tables, step 3: drop old tables
2 parents daeb9e6 + 00b61c4 commit 53269ba

2 files changed

Lines changed: 131 additions & 0 deletions

File tree

fineract-working-capital-loan/src/main/resources/db/changelog/tenant/module/workingcapitalloan/module-changelog-master.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,5 @@
5050
<include relativeToChangelogFile="true" file="parts/0026_wc_loan_repayment_classification_code.xml"/>
5151
<include relativeToChangelogFile="true" file="parts/0027_wc_loan_repayment_transaction_external_events.xml"/>
5252
<include relativeToChangelogFile="true" file="parts/0028_create_wc_delinquency_and_breach_configuration_tables.xml"/>
53+
<include relativeToChangelogFile="true" file="parts/0029_drop_legacy_wc_configuration_tables.xml"/>
5354
</databaseChangeLog>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one
5+
or more contributor license agreements. See the NOTICE file
6+
distributed with this work for additional information
7+
regarding copyright ownership. The ASF licenses this file
8+
to you under the Apache License, Version 2.0 (the
9+
"License"); you may not use this file except in compliance
10+
with the License. You may obtain a copy of the License at
11+
12+
http://www.apache.org/licenses/LICENSE-2.0
13+
14+
Unless required by applicable law or agreed to in writing,
15+
software distributed under the License is distributed on an
16+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17+
KIND, either express or implied. See the License for the
18+
specific language governing permissions and limitations
19+
under the License.
20+
21+
-->
22+
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
23+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
24+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.3.xsd">
25+
26+
<changeSet id="wclp-0029-0-copy-missing-wc-delinquency-configuration-data" author="fineract">
27+
<preConditions onFail="MARK_RAN">
28+
<and>
29+
<tableExists tableName="m_delinquency_payment_rule"/>
30+
<tableExists tableName="m_wc_delinquency_configuration"/>
31+
</and>
32+
</preConditions>
33+
<sql>
34+
INSERT INTO m_wc_delinquency_configuration
35+
(id, created_by, last_modified_by, bucket_id, frequency, frequency_type, minimum_payment, minimum_payment_type, created_on_utc, last_modified_on_utc)
36+
SELECT src.id, src.created_by, src.last_modified_by, src.bucket_id, src.frequency, src.frequency_type, src.minimum_payment,
37+
src.minimum_payment_type, src.created_on_utc, src.last_modified_on_utc
38+
FROM m_delinquency_payment_rule src
39+
WHERE NOT EXISTS (
40+
SELECT 1 FROM m_wc_delinquency_configuration dst
41+
WHERE dst.id = src.id
42+
);
43+
</sql>
44+
</changeSet>
45+
46+
<changeSet id="wclp-0029-0-1-sync-wc-delinquency-configuration-sequence-postgresql" author="fineract" context="postgresql">
47+
<preConditions onFail="MARK_RAN">
48+
<and>
49+
<tableExists tableName="m_wc_delinquency_configuration"/>
50+
<sequenceExists sequenceName="m_wc_delinquency_configuration_id_seq"/>
51+
</and>
52+
</preConditions>
53+
<sql>
54+
SELECT setval(
55+
'm_wc_delinquency_configuration_id_seq',
56+
COALESCE((SELECT MAX(id) FROM m_wc_delinquency_configuration), 0) + 1,
57+
false
58+
);
59+
</sql>
60+
</changeSet>
61+
62+
<changeSet id="wclp-0029-1-drop-legacy-delinquency-payment-rule-table" author="fineract">
63+
<preConditions onFail="MARK_RAN">
64+
<and>
65+
<tableExists tableName="m_wc_delinquency_configuration"/>
66+
<tableExists tableName="m_delinquency_payment_rule"/>
67+
</and>
68+
</preConditions>
69+
<dropTable tableName="m_delinquency_payment_rule"/>
70+
</changeSet>
71+
72+
<changeSet id="wclp-0029-2-drop-legacy-loan-product-breach-fk" author="fineract">
73+
<preConditions onFail="MARK_RAN">
74+
<foreignKeyConstraintExists foreignKeyName="FK_m_wc_loan_product_breach"/>
75+
</preConditions>
76+
<dropForeignKeyConstraint baseTableName="m_wc_loan_product" constraintName="FK_m_wc_loan_product_breach"/>
77+
</changeSet>
78+
79+
<changeSet id="wclp-0029-3-drop-legacy-loan-breach-fk" author="fineract">
80+
<preConditions onFail="MARK_RAN">
81+
<foreignKeyConstraintExists foreignKeyName="FK_m_wc_loan_breach"/>
82+
</preConditions>
83+
<dropForeignKeyConstraint baseTableName="m_wc_loan" constraintName="FK_m_wc_loan_breach"/>
84+
</changeSet>
85+
86+
<changeSet id="wclp-0029-3-1-copy-missing-wc-breach-configuration-data" author="fineract">
87+
<preConditions onFail="MARK_RAN">
88+
<and>
89+
<tableExists tableName="m_wc_breach"/>
90+
<tableExists tableName="m_wc_breach_configuration"/>
91+
</and>
92+
</preConditions>
93+
<sql>
94+
INSERT INTO m_wc_breach_configuration
95+
(id, name, breach_frequency, breach_frequency_type, breach_amount_calculation_type, breach_amount)
96+
SELECT src.id, src.name, src.breach_frequency, src.breach_frequency_type, src.breach_amount_calculation_type, src.breach_amount
97+
FROM m_wc_breach src
98+
WHERE NOT EXISTS (
99+
SELECT 1 FROM m_wc_breach_configuration dst
100+
WHERE dst.id = src.id
101+
);
102+
</sql>
103+
</changeSet>
104+
105+
<changeSet id="wclp-0029-3-2-sync-wc-breach-configuration-sequence-postgresql" author="fineract" context="postgresql">
106+
<preConditions onFail="MARK_RAN">
107+
<and>
108+
<tableExists tableName="m_wc_breach_configuration"/>
109+
<sequenceExists sequenceName="m_wc_breach_configuration_id_seq"/>
110+
</and>
111+
</preConditions>
112+
<sql>
113+
SELECT setval(
114+
'm_wc_breach_configuration_id_seq',
115+
COALESCE((SELECT MAX(id) FROM m_wc_breach_configuration), 0) + 1,
116+
false
117+
);
118+
</sql>
119+
</changeSet>
120+
121+
<changeSet id="wclp-0029-4-drop-legacy-breach-table" author="fineract">
122+
<preConditions onFail="MARK_RAN">
123+
<and>
124+
<tableExists tableName="m_wc_breach_configuration"/>
125+
<tableExists tableName="m_wc_breach"/>
126+
</and>
127+
</preConditions>
128+
<dropTable tableName="m_wc_breach"/>
129+
</changeSet>
130+
</databaseChangeLog>

0 commit comments

Comments
 (0)