Skip to content

Commit

Permalink
FINERACT-1498: Switching from Flyway to Liqubase migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
galovics authored and vidakovic committed Feb 19, 2022
1 parent 746c589 commit 45bed0a
Show file tree
Hide file tree
Showing 34 changed files with 30,137 additions and 189 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ License
This project is licensed under Apache License Version 2.0. See <https://github.com/apache/incubator-fineract/blob/develop/LICENSE.md> for reference.

The Connector/J JDBC Driver client library from MariaDB.org, which is licensed under the LGPL,
is used in development when running integration tests that use the Flyway library. That JDBC
is used in development when running integration tests that use the Liquibase library. That JDBC
driver is however not included in and distributed with the Fineract product and is not
required to use the product.
If you are developer and object to using the LGPL licensed Connector/J JDBC driver,
simply do not run the integration tests that use the Flyway library and/or use another JDBC driver.
simply do not run the integration tests that use the Liquibase library and/or use another JDBC driver.
As discussed in [LEGAL-462](https://issues.apache.org/jira/browse/LEGAL-462), this project therefore
complies with the [Apache Software Foundation third-party license policy](https://www.apache.org/legal/resolved.html).

Expand Down
9 changes: 3 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ buildscript {
dependencies {
classpath 'com.bmuschko:gradle-cargo-plugin:2.8.0'
classpath 'org.apache.openjpa:openjpa:3.2.0' // when upgrading, also change OpenJPA version repeated in fineract-provider/build.gradle!
classpath('com.google.cloud.tools:jib-layer-filter-extension-gradle:0.1.0')
}
}

Expand Down Expand Up @@ -182,12 +183,8 @@ allprojects {
dependency "com.google.code.findbugs:jsr305:3.0.2"
dependency "commons-codec:commons-codec:1.15"

dependency ('org.flywaydb:flyway-core:8.1.0') {
// https://issues.apache.org/jira/browse/FINERACT-1172
// https://github.com/apache/fineract/pull/1355
// https://github.com/flyway/flyway/issues/2957
// exclude conflicting non-<optional> dependencies from https://github.com/flyway/flyway/blob/master/flyway-core/pom.xml
exclude 'software.amazon.awssdk:s3'
dependency ('org.liquibase:liquibase-core:4.5.0') {
exclude 'javax.xml.bind:jaxb-api'
}

dependency ('org.dom4j:dom4j:2.1.3') {
Expand Down
13 changes: 13 additions & 0 deletions fineract-provider/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,19 @@ jib {
}
}
}

pluginExtensions {
pluginExtension {
implementation = 'com.google.cloud.tools.jib.gradle.extension.layerfilter.JibLayerFilterExtension'
configuration {
filters {
filter {
glob = '/app/resources/**'
}
}
}
}
}
}

tasks.jibDockerBuild.dependsOn = ["bootJar"]
Expand Down
2 changes: 1 addition & 1 deletion fineract-provider/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ dependencies {
'org.apache.poi:poi-ooxml-schemas',
'org.apache.tika:tika-core',

'org.flywaydb:flyway-core',
'org.liquibase:liquibase-core',

'com.github.librepdf:openpdf',
'com.github.spullara.mustache.java:compiler',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@

import org.apache.fineract.infrastructure.core.config.FineractProperties;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration;
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.ComponentScan;
Expand All @@ -38,11 +39,11 @@

@Configuration
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class,
DataSourceTransactionManagerAutoConfiguration.class, FlywayAutoConfiguration.class, GsonAutoConfiguration.class,
JdbcTemplateAutoConfiguration.class })
DataSourceTransactionManagerAutoConfiguration.class, GsonAutoConfiguration.class, JdbcTemplateAutoConfiguration.class,
LiquibaseAutoConfiguration.class })
@EnableTransactionManagement
@EnableWebSecurity
@EnableConfigurationProperties({ FineractProperties.class })
@EnableConfigurationProperties({ FineractProperties.class, LiquibaseProperties.class })
@ComponentScan(basePackages = "org.apache.fineract.**")
public abstract class AbstractApplicationConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public Connection getConnection() throws SQLException {
return determineTargetDataSource().getConnection();
}

private DataSource determineTargetDataSource() {
public DataSource determineTargetDataSource() {
return this.dataSourceServiceFactory.determineDataSourceService().retrieveDataSource();
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* 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:https://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.
*/
package org.apache.fineract.infrastructure.core.service.database;

import static org.apache.commons.collections4.CollectionUtils.isNotEmpty;

import java.sql.SQLException;
import java.util.Collection;
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class DatabaseIndependentQueryService implements DatabaseQueryService {

private final Collection<DatabaseQueryService> queryServices;

@Autowired
public DatabaseIndependentQueryService(Collection<DatabaseQueryService> queryServices) {
this.queryServices = queryServices;
}

private DatabaseQueryService choose(DataSource dataSource) {
try {
DatabaseQueryService result = null;
if (isNotEmpty(queryServices)) {
result = queryServices.stream().filter(qs -> qs.isSupported(dataSource)).findAny().orElse(null);
}
if (result == null) {
throw new IllegalStateException("DataSource not supported: " + dataSource.getConnection().getMetaData().getURL());
}
return result;
} catch (SQLException e) {
throw new RuntimeException("Error while trying to choose the proper query service", e);
}
}

@Override
public boolean isSupported(DataSource dataSource) {
return true;
}

@Override
public boolean isTablePresent(DataSource dataSource, String tableName) {
return choose(dataSource).isTablePresent(dataSource, tableName);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* 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:https://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.
*/
package org.apache.fineract.infrastructure.core.service.database;

import javax.sql.DataSource;

public interface DatabaseQueryService {

boolean isSupported(DataSource dataSource);

boolean isTablePresent(DataSource dataSource, String tableName);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* 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:https://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.
*/
package org.apache.fineract.infrastructure.core.service.database;

public enum DatabaseType {
MYSQL
}
Loading

0 comments on commit 45bed0a

Please sign in to comment.