|
| 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-0028-1-create-wc-delinquency-configuration-table" author="fineract"> |
| 27 | + <preConditions onFail="MARK_RAN"> |
| 28 | + <not> |
| 29 | + <tableExists tableName="m_wc_delinquency_configuration"/> |
| 30 | + </not> |
| 31 | + </preConditions> |
| 32 | + <createTable tableName="m_wc_delinquency_configuration"> |
| 33 | + <column autoIncrement="true" name="id" type="BIGINT"> |
| 34 | + <constraints nullable="false" primaryKey="true" primaryKeyName="pk_m_wc_delinquency_configuration"/> |
| 35 | + </column> |
| 36 | + <column name="created_by" type="BIGINT"> |
| 37 | + <constraints nullable="false"/> |
| 38 | + </column> |
| 39 | + <column name="last_modified_by" type="BIGINT"> |
| 40 | + <constraints nullable="false"/> |
| 41 | + </column> |
| 42 | + <column name="bucket_id" type="BIGINT"> |
| 43 | + <constraints nullable="false"/> |
| 44 | + </column> |
| 45 | + <column name="frequency" type="INT"> |
| 46 | + <constraints nullable="false"/> |
| 47 | + </column> |
| 48 | + <column name="frequency_type" type="VARCHAR(50)"> |
| 49 | + <constraints nullable="false"/> |
| 50 | + </column> |
| 51 | + <column name="minimum_payment" type="DECIMAL(19, 6)"> |
| 52 | + <constraints nullable="false"/> |
| 53 | + </column> |
| 54 | + <column name="minimum_payment_type" type="VARCHAR(50)"> |
| 55 | + <constraints nullable="false"/> |
| 56 | + </column> |
| 57 | + </createTable> |
| 58 | + <addUniqueConstraint tableName="m_wc_delinquency_configuration" columnNames="bucket_id" |
| 59 | + constraintName="uc_m_wc_delinquency_configuration_bucket"/> |
| 60 | + <addForeignKeyConstraint baseTableName="m_wc_delinquency_configuration" baseColumnNames="bucket_id" |
| 61 | + referencedTableName="m_delinquency_bucket" referencedColumnNames="id" |
| 62 | + constraintName="FK_M_WC_DELINQUENCY_CONFIGURATION_ON_BUCKET"/> |
| 63 | + </changeSet> |
| 64 | + |
| 65 | + <changeSet id="wclp-0028-2-add-wc-delinquency-utc-columns-mysql" author="fineract" context="mysql"> |
| 66 | + <preConditions onFail="MARK_RAN"> |
| 67 | + <and> |
| 68 | + <tableExists tableName="m_wc_delinquency_configuration"/> |
| 69 | + <not> |
| 70 | + <columnExists tableName="m_wc_delinquency_configuration" columnName="created_on_utc"/> |
| 71 | + </not> |
| 72 | + </and> |
| 73 | + </preConditions> |
| 74 | + <addColumn tableName="m_wc_delinquency_configuration"> |
| 75 | + <column name="created_on_utc" type="DATETIME"/> |
| 76 | + <column name="last_modified_on_utc" type="DATETIME"/> |
| 77 | + </addColumn> |
| 78 | + </changeSet> |
| 79 | + |
| 80 | + <changeSet id="wclp-0028-3-add-wc-delinquency-utc-columns-postgresql" author="fineract" context="postgresql"> |
| 81 | + <preConditions onFail="MARK_RAN"> |
| 82 | + <and> |
| 83 | + <tableExists tableName="m_wc_delinquency_configuration"/> |
| 84 | + <not> |
| 85 | + <columnExists tableName="m_wc_delinquency_configuration" columnName="created_on_utc"/> |
| 86 | + </not> |
| 87 | + </and> |
| 88 | + </preConditions> |
| 89 | + <addColumn tableName="m_wc_delinquency_configuration"> |
| 90 | + <column name="created_on_utc" type="TIMESTAMP WITH TIME ZONE"/> |
| 91 | + <column name="last_modified_on_utc" type="TIMESTAMP WITH TIME ZONE"/> |
| 92 | + </addColumn> |
| 93 | + </changeSet> |
| 94 | + |
| 95 | + <changeSet id="wclp-0028-3-1-copy-wc-delinquency-configuration-data" author="fineract"> |
| 96 | + <preConditions onFail="MARK_RAN"> |
| 97 | + <and> |
| 98 | + <tableExists tableName="m_delinquency_payment_rule"/> |
| 99 | + <tableExists tableName="m_wc_delinquency_configuration"/> |
| 100 | + </and> |
| 101 | + </preConditions> |
| 102 | + <sql> |
| 103 | + INSERT INTO m_wc_delinquency_configuration |
| 104 | + (id, created_by, last_modified_by, bucket_id, frequency, frequency_type, minimum_payment, minimum_payment_type, created_on_utc, last_modified_on_utc) |
| 105 | + SELECT src.id, src.created_by, src.last_modified_by, src.bucket_id, src.frequency, src.frequency_type, src.minimum_payment, |
| 106 | + src.minimum_payment_type, src.created_on_utc, src.last_modified_on_utc |
| 107 | + FROM m_delinquency_payment_rule src |
| 108 | + WHERE NOT EXISTS ( |
| 109 | + SELECT 1 FROM m_wc_delinquency_configuration dst |
| 110 | + WHERE dst.id = src.id |
| 111 | + ); |
| 112 | + </sql> |
| 113 | + </changeSet> |
| 114 | + |
| 115 | + <changeSet id="wclp-0028-3-2-sync-wc-delinquency-configuration-sequence-postgresql" author="fineract" context="postgresql"> |
| 116 | + <preConditions onFail="MARK_RAN"> |
| 117 | + <and> |
| 118 | + <tableExists tableName="m_wc_delinquency_configuration"/> |
| 119 | + <sequenceExists sequenceName="m_wc_delinquency_configuration_id_seq"/> |
| 120 | + </and> |
| 121 | + </preConditions> |
| 122 | + <sql> |
| 123 | + SELECT setval( |
| 124 | + 'm_wc_delinquency_configuration_id_seq', |
| 125 | + COALESCE((SELECT MAX(id) FROM m_wc_delinquency_configuration), 0) + 1, |
| 126 | + false |
| 127 | + ); |
| 128 | + </sql> |
| 129 | + </changeSet> |
| 130 | + |
| 131 | + <changeSet id="wclp-0028-4-create-wc-breach-configuration-table" author="fineract"> |
| 132 | + <preConditions onFail="MARK_RAN"> |
| 133 | + <not> |
| 134 | + <tableExists tableName="m_wc_breach_configuration"/> |
| 135 | + </not> |
| 136 | + </preConditions> |
| 137 | + <createTable tableName="m_wc_breach_configuration"> |
| 138 | + <column name="id" type="BIGINT" autoIncrement="true"> |
| 139 | + <constraints nullable="false" primaryKey="true" primaryKeyName="PK_m_wc_breach_configuration"/> |
| 140 | + </column> |
| 141 | + <column name="name" type="VARCHAR(100)"> |
| 142 | + <constraints nullable="false"/> |
| 143 | + </column> |
| 144 | + <column name="breach_frequency" type="INT"/> |
| 145 | + <column name="breach_frequency_type" type="VARCHAR(50)"/> |
| 146 | + <column name="breach_amount_calculation_type" type="VARCHAR(50)"/> |
| 147 | + <column name="breach_amount" type="DECIMAL(19,6)"/> |
| 148 | + </createTable> |
| 149 | + <createIndex tableName="m_wc_breach_configuration" indexName="uq_m_wc_breach_configuration_name" unique="true"> |
| 150 | + <column name="name"/> |
| 151 | + </createIndex> |
| 152 | + </changeSet> |
| 153 | + |
| 154 | + <changeSet id="wclp-0028-4-1-copy-wc-breach-configuration-data" author="fineract"> |
| 155 | + <preConditions onFail="MARK_RAN"> |
| 156 | + <and> |
| 157 | + <tableExists tableName="m_wc_breach"/> |
| 158 | + <tableExists tableName="m_wc_breach_configuration"/> |
| 159 | + </and> |
| 160 | + </preConditions> |
| 161 | + <sql> |
| 162 | + INSERT INTO m_wc_breach_configuration |
| 163 | + (id, name, breach_frequency, breach_frequency_type, breach_amount_calculation_type, breach_amount) |
| 164 | + SELECT src.id, src.name, src.breach_frequency, src.breach_frequency_type, src.breach_amount_calculation_type, src.breach_amount |
| 165 | + FROM m_wc_breach src |
| 166 | + WHERE NOT EXISTS ( |
| 167 | + SELECT 1 FROM m_wc_breach_configuration dst |
| 168 | + WHERE dst.id = src.id |
| 169 | + ); |
| 170 | + </sql> |
| 171 | + </changeSet> |
| 172 | + |
| 173 | + <changeSet id="wclp-0028-4-2-sync-wc-breach-configuration-sequence-postgresql" author="fineract" context="postgresql"> |
| 174 | + <preConditions onFail="MARK_RAN"> |
| 175 | + <and> |
| 176 | + <tableExists tableName="m_wc_breach_configuration"/> |
| 177 | + <sequenceExists sequenceName="m_wc_breach_configuration_id_seq"/> |
| 178 | + </and> |
| 179 | + </preConditions> |
| 180 | + <sql> |
| 181 | + SELECT setval( |
| 182 | + 'm_wc_breach_configuration_id_seq', |
| 183 | + COALESCE((SELECT MAX(id) FROM m_wc_breach_configuration), 0) + 1, |
| 184 | + false |
| 185 | + ); |
| 186 | + </sql> |
| 187 | + </changeSet> |
| 188 | + |
| 189 | + <changeSet id="wclp-0028-5-point-breach-fks-to-new-table" author="fineract"> |
| 190 | + <preConditions onFail="MARK_RAN"> |
| 191 | + <and> |
| 192 | + <tableExists tableName="m_wc_breach_configuration"/> |
| 193 | + <foreignKeyConstraintExists foreignKeyName="FK_m_wc_loan_product_breach"/> |
| 194 | + <foreignKeyConstraintExists foreignKeyName="FK_m_wc_loan_breach"/> |
| 195 | + </and> |
| 196 | + </preConditions> |
| 197 | + <dropForeignKeyConstraint baseTableName="m_wc_loan_product" constraintName="FK_m_wc_loan_product_breach"/> |
| 198 | + <addForeignKeyConstraint baseTableName="m_wc_loan_product" baseColumnNames="breach_id" |
| 199 | + constraintName="FK_m_wc_loan_product_breach_cfg" referencedTableName="m_wc_breach_configuration" |
| 200 | + referencedColumnNames="id"/> |
| 201 | + <dropForeignKeyConstraint baseTableName="m_wc_loan" constraintName="FK_m_wc_loan_breach"/> |
| 202 | + <addForeignKeyConstraint baseTableName="m_wc_loan" baseColumnNames="breach_id" |
| 203 | + constraintName="FK_m_wc_loan_breach_cfg" referencedTableName="m_wc_breach_configuration" |
| 204 | + referencedColumnNames="id"/> |
| 205 | + </changeSet> |
| 206 | +</databaseChangeLog> |
0 commit comments