FINERACT-1498: Switching from Flyway to Liqubase migrations

This commit is contained in:
Arnold Galovics
2022-02-19 22:55:32 +01:00
committed by Aleksandar Vidakovic
parent 746c589a6e
commit 45bed0a05a
34 changed files with 30137 additions and 189 deletions
@@ -74,3 +74,17 @@ spring.datasource.hikari.dataSourceProperties['maintainTimeStats']=${FINERACT_HI
# TODO FINERACT-890: <prop key="logger">com.mysql.cj.log.Slf4JLogger</prop>
spring.datasource.hikari.dataSourceProperties['logSlowQueries']=${FINERACT_HIKARI_DS_PROPERTIES_LOG_SLOW_QUERIES:true}
spring.datasource.hikari.dataSourceProperties['dumpQueriesOnException']=${FINERACT_HIKARI_DS_PROPERTIES_DUMP_QUERIES_IN_EXCEPTION:true}
# Liquibase configuration
spring.liquibase.enabled=true
spring.liquibase.changeLog=classpath:/db/changelog/db.changelog-master.xml
spring.liquibase.parameters.fineract.tenant.identifier=${fineract.tenant.identifier}
spring.liquibase.parameters.fineract.tenant.description=${fineract.tenant.description}
spring.liquibase.parameters.fineract.tenant.timezone=${fineract.tenant.timezone}
spring.liquibase.parameters.fineract.tenant.schema-name=${fineract.tenant.name}
spring.liquibase.parameters.fineract.tenant.host=${fineract.tenant.host}
spring.liquibase.parameters.fineract.tenant.port=${fineract.tenant.port}
spring.liquibase.parameters.fineract.tenant.username=${fineract.tenant.username}
spring.liquibase.parameters.fineract.tenant.password=${fineract.tenant.password}
spring.liquibase.parameters.fineract.tenant.parameters=${fineract.tenant.parameters}
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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">
<property name="current_date" value="CURDATE()" context="mysql"/>
<property name="current_datetime" value="NOW()"/>
<include file="tenant-store/initial-switch-changelog-tenant-store.xml" relativeToChangelogFile="true" context="tenant_store_db AND initial_switch"/>
<include file="tenant-store/changelog-tenant-store.xml" relativeToChangelogFile="true" context="tenant_store_db AND !initial_switch"/>
<include file="tenant/initial-switch-changelog-tenant.xml" relativeToChangelogFile="true" context="tenant_db AND initial_switch"/>
<include file="tenant/changelog-tenant.xml" relativeToChangelogFile="true" context="tenant_db AND !initial_switch"/>
</databaseChangeLog>
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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">
<!-- An example how to include upcoming changes -->
<!-- <include file="parts/0003_upcoming_change.xml" relativeToChangelogFile="true"/> -->
</databaseChangeLog>
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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">
<include file="parts/0001_initial_schema.xml" relativeToChangelogFile="true" context="initial_switch"/>
<include file="parts/0002_initial_data.xml" relativeToChangelogFile="true" context="initial_switch"/>
<!-- The first 2 changelog files are ran with the initial_switch context to handle the Flyway -> Liquibase migration -->
<!-- The rest of the changelogs will not need this context set -->
</databaseChangeLog>
@@ -0,0 +1,122 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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">
<changeSet author="fineract" id="1">
<createTable tableName="tenant_server_connections">
<column autoIncrement="true" name="id" type="BIGINT">
<constraints nullable="false" primaryKey="true"/>
</column>
<column defaultValue="localhost" name="schema_server" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
<column name="schema_name" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
<column defaultValue="3306" name="schema_server_port" type="VARCHAR(10)">
<constraints nullable="false"/>
</column>
<column defaultValue="root" name="schema_username" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
<column defaultValue="mysql" name="schema_password" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
<column defaultValueNumeric="1" name="auto_update" type="TINYINT">
<constraints nullable="false"/>
</column>
<column defaultValueNumeric="5" name="pool_initial_size" type="INT"/>
<column defaultValueNumeric="30000" name="pool_validation_interval" type="INT"/>
<column defaultValueNumeric="1" name="pool_remove_abandoned" type="TINYINT"/>
<column defaultValueNumeric="60" name="pool_remove_abandoned_timeout" type="INT"/>
<column defaultValueNumeric="1" name="pool_log_abandoned" type="TINYINT"/>
<column defaultValueNumeric="50" name="pool_abandon_when_percentage_full" type="INT"/>
<column defaultValueNumeric="1" name="pool_test_on_borrow" type="TINYINT"/>
<column defaultValueNumeric="40" name="pool_max_active" type="INT"/>
<column defaultValueNumeric="20" name="pool_min_idle" type="INT"/>
<column defaultValueNumeric="10" name="pool_max_idle" type="INT"/>
<column defaultValueNumeric="60" name="pool_suspect_timeout" type="INT"/>
<column defaultValueNumeric="34000" name="pool_time_between_eviction_runs_millis" type="INT"/>
<column defaultValueNumeric="60000" name="pool_min_evictable_idle_time_millis" type="INT"/>
<column defaultValueNumeric="0" name="deadlock_max_retries" type="INT"/>
<column defaultValueNumeric="1" name="deadlock_max_retry_interval" type="INT"/>
<column name="schema_connection_parameters" type="TEXT"/>
</createTable>
</changeSet>
<changeSet author="fineract" id="2">
<createTable tableName="tenants">
<column autoIncrement="true" name="id" type="BIGINT">
<constraints nullable="false" primaryKey="true"/>
</column>
<column name="identifier" type="VARCHAR(100)">
<constraints nullable="false" unique="true"/>
</column>
<column name="name" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
<column name="timezone_id" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
<column defaultValueComputed="NULL" name="country_id" type="INT"/>
<column defaultValueComputed="NULL" name="joined_date" type="date"/>
<column defaultValueComputed="NULL" name="created_date" type="datetime"/>
<column defaultValueComputed="NULL" name="lastmodified_date" type="datetime"/>
<column name="oltp_id" type="BIGINT">
<constraints nullable="false"/>
</column>
<column name="report_id" type="BIGINT">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>
<changeSet author="fineract" id="3">
<createTable tableName="timezones">
<column autoIncrement="true" name="id" type="INT">
<constraints nullable="false" primaryKey="true"/>
</column>
<column name="country_code" type="VARCHAR(2)">
<constraints nullable="false"/>
</column>
<column name="timezonename" type="VARCHAR(100)">
<constraints nullable="false"/>
</column>
<column name="comments" type="VARCHAR(150)"/>
</createTable>
</changeSet>
<changeSet author="fineract" id="4">
<createIndex indexName="fk_oltp_id" tableName="tenants">
<column name="oltp_id"/>
</createIndex>
</changeSet>
<changeSet author="fineract" id="5">
<createIndex indexName="fk_report_id" tableName="tenants">
<column name="report_id"/>
</createIndex>
</changeSet>
<changeSet author="fineract" id="6">
<addForeignKeyConstraint baseColumnNames="oltp_id" baseTableName="tenants" constraintName="fk_oltp_id" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="id" referencedTableName="tenant_server_connections" validate="true"/>
</changeSet>
<changeSet author="fineract" id="7">
<addForeignKeyConstraint baseColumnNames="report_id" baseTableName="tenants" constraintName="fk_report_id" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="id" referencedTableName="tenant_server_connections" validate="true"/>
</changeSet>
</databaseChangeLog>
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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">
<!-- An example how to include upcoming changes -->
<!-- <include file="parts/0003_upcoming_change.xml" relativeToChangelogFile="true"/> -->
</databaseChangeLog>
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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">
<include file="parts/0001_initial_schema.xml" relativeToChangelogFile="true" context="initial_switch"/>
<include file="parts/0002_initial_data.xml" relativeToChangelogFile="true" context="initial_switch"/>
<!-- The first 2 changelog files are ran with the initial_switch context to handle the Flyway -> Liquibase migration -->
<!-- The rest of the changelogs will not need this context set -->
</databaseChangeLog>
File diff suppressed because one or more lines are too long
@@ -36,7 +36,8 @@
<appender-ref ref="CONSOLE" />
</root>
<!-- But these two INFO are still handy ;-) just to see when it's up and running -->
<!-- But these three INFO are still handy ;-) just to see when it's up and running -->
<logger name="org.springframework.boot.web.embedded.tomcat.TomcatWebServer" level="info" />
<logger name="org.apache.fineract.ServerApplication" level="info" />
<logger name="liquibase" level="info" />
</configuration>