|
| 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