fineract-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vorbur...@apache.org
Subject [fineract] branch develop updated: bump flyway from 2.1.1 to 6.4.1
Date Mon, 11 May 2020 10:21:49 GMT
This is an automated email from the ASF dual-hosted git repository.

vorburger pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/fineract.git


The following commit(s) were added to refs/heads/develop by this push:
     new 2285797  bump flyway from 2.1.1 to 6.4.1
2285797 is described below

commit 2285797effed1b4af205da06ed77a12263e9365b
Author: xurror <kaze.nasser@outlook.com>
AuthorDate: Sun May 10 18:58:07 2020 +0100

    bump flyway from 2.1.1 to 6.4.1
---
 fineract-provider/build.gradle                     |  4 +--
 fineract-provider/dependencies.gradle              |  2 +-
 .../core/service/TenantDatabaseUpgradeService.java | 37 ++++++++++++++--------
 ...ert_script_for_charges_paid_by_for_accruals.sql |  2 +-
 4 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/fineract-provider/build.gradle b/fineract-provider/build.gradle
index d92a024..fec5e5e 100644
--- a/fineract-provider/build.gradle
+++ b/fineract-provider/build.gradle
@@ -94,7 +94,7 @@ dependencyManagement {
         dependency 'com.lowagie:itext:2.1.7'
         dependency 'com.lowagie:itext-rtf:2.1.7'
         dependency 'org.mnode.ical4j:ical4j:1.0.7'
-        dependency 'com.googlecode.flyway:flyway-core:2.1.1'
+        dependency 'org.flywaydb:flyway-core:6.4.1'
         dependency 'org.quartz-scheduler:quartz:+'
         dependency 'com.amazonaws:aws-java-sdk-s3:1.11.779'
         dependency 'net.sf.ehcache:ehcache:+'
@@ -105,7 +105,7 @@ dependencyManagement {
         dependency 'io.swagger:swagger-jersey-jaxrs:1.6.1'
         dependency 'jakarta.management.j2ee:jakarta.management.j2ee-api:1.1.4'
         dependency 'jakarta.jms:jakarta.jms-api:2.0.3'
-	dependency 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.3'
+	    dependency 'jakarta.xml.bind:jakarta.xml.bind-api:2.3.3'
         dependency 'org.apache.activemq:activemq-broker:+'
         dependency 'org.apache.bval:org.apache.bval.bundle:2.0.3'
         dependency 'junit:junit:+'
diff --git a/fineract-provider/dependencies.gradle b/fineract-provider/dependencies.gradle
index bfce3e5..ec2b9cb 100644
--- a/fineract-provider/dependencies.gradle
+++ b/fineract-provider/dependencies.gradle
@@ -63,7 +63,7 @@ dependencies {
             'org.apache.tika:tika-core',
 
             'org.drizzle.jdbc:drizzle-jdbc',
-            'com.googlecode.flyway:flyway-core',
+            'org.flywaydb:flyway-core',
 
             'net.sf.ehcache:ehcache',
             'com.lowagie:itext',
diff --git a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TenantDatabaseUpgradeService.java
b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TenantDatabaseUpgradeService.java
index c678644..a80a6b1 100644
--- a/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TenantDatabaseUpgradeService.java
+++ b/fineract-provider/src/main/java/org/apache/fineract/infrastructure/core/service/TenantDatabaseUpgradeService.java
@@ -18,9 +18,6 @@
  */
 package org.apache.fineract.infrastructure.core.service;
 
-import com.googlecode.flyway.core.Flyway;
-import com.googlecode.flyway.core.api.FlywayException;
-import com.googlecode.flyway.core.util.jdbc.DriverDataSource;
 import java.util.List;
 import java.util.Map;
 import javax.annotation.PostConstruct;
@@ -29,6 +26,9 @@ import org.apache.fineract.infrastructure.core.boot.JDBCDriverConfig;
 import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenant;
 import org.apache.fineract.infrastructure.core.domain.FineractPlatformTenantConnection;
 import org.apache.fineract.infrastructure.security.service.TenantDetailsService;
+import org.flywaydb.core.Flyway;
+import org.flywaydb.core.api.FlywayException;
+import org.flywaydb.core.internal.jdbc.DriverDataSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -62,13 +62,19 @@ public class TenantDatabaseUpgradeService {
         for (final FineractPlatformTenant tenant : tenants) {
             final FineractPlatformTenantConnection connection = tenant.getConnection();
             if (connection.isAutoUpdateEnabled()) {
-                final Flyway flyway = new Flyway();
+
                 String connectionProtocol = driverConfig.constructProtocol(connection.getSchemaServer(),
connection.getSchemaServerPort(), connection.getSchemaName()) ;
-                DriverDataSource source = new DriverDataSource(driverConfig.getDriverClassName(),
connectionProtocol, connection.getSchemaUsername(), connection.getSchemaPassword()) ;
-                flyway.setDataSource(source);
-                flyway.setLocations("sql/migrations/core_db");
-                flyway.setOutOfOrder(true);
+                DriverDataSource source = new DriverDataSource(Thread.currentThread().getContextClassLoader(),
driverConfig.getDriverClassName(), connectionProtocol, connection.getSchemaUsername(), connection.getSchemaPassword());
+
+                final Flyway flyway = Flyway.configure()
+                    .dataSource(source)
+                    .locations("sql/migrations/core_db")
+                    .outOfOrder(true)
+                    .placeholderReplacement(false)
+                    .load();
+
                 try {
+                    flyway.repair();
                     flyway.migrate();
                 } catch (FlywayException e) {
                     String betterMessage = e.getMessage() + "; for Tenant DB URL: " + connectionProtocol
+ ", username: "
@@ -90,15 +96,18 @@ public class TenantDatabaseUpgradeService {
         String dbPwd = getEnvVar("FINERACT_DEFAULT_TENANTDB_PWD", "mysql");
         LOG.info("upgradeTenantDB: FINERACT_DEFAULT_TENANTDB_HOSTNAME = {}, FINERACT_DEFAULT_TENANTDB_PORT
= {}", dbHostname, dbPort);
 
-        final Flyway flyway = new Flyway();
-        flyway.setDataSource(tenantDataSource);
-        flyway.setLocations("sql/migrations/list_db");
-        flyway.setOutOfOrder(true);
-        flyway.setPlaceholders(Map.of( // FINERACT-773
+        final Flyway flyway = Flyway.configure()
+            .dataSource(tenantDataSource)
+            .locations("sql/migrations/list_db")
+            .outOfOrder(true)
+            .placeholders(Map.of( // FINERACT-773
                 "fineract_default_tenantdb_hostname", dbHostname,
                 "fineract_default_tenantdb_port",     dbPort,
                 "fineract_default_tenantdb_uid",      dbUid,
-                "fineract_default_tenantdb_pwd",      dbPwd));
+                "fineract_default_tenantdb_pwd",      dbPwd))
+            .load();
+
+        flyway.repair();
         flyway.migrate();
     }
 
diff --git a/fineract-provider/src/main/resources/sql/migrations/core_db/V204__insert_script_for_charges_paid_by_for_accruals.sql
b/fineract-provider/src/main/resources/sql/migrations/core_db/V204__insert_script_for_charges_paid_by_for_accruals.sql
index 21f4acd..74dd44a 100755
--- a/fineract-provider/src/main/resources/sql/migrations/core_db/V204__insert_script_for_charges_paid_by_for_accruals.sql
+++ b/fineract-provider/src/main/resources/sql/migrations/core_db/V204__insert_script_for_charges_paid_by_for_accruals.sql
@@ -17,4 +17,4 @@
 -- under the License.
 --
 
-insert into m_loan_charge_paid_by (`loan_transaction_id`,`loan_charge_id`,`amount`) select
lt.id, lc.id,  if(lic.amount is null,lc.amount,lic.amount)  from m_loan_transaction lt join
m_loan_repayment_schedule rs on rs.loan_id = lt.loan_id and rs.duedate = lt.transaction_date
join m_loan_charge lc on lc.loan_id = rs.loan_id and ((lc.due_for_collection_as_of_date >
rs.fromdate and lc.due_for_collection_as_of_date <= rs.duedate) or lc.charge_time_enum
= 8) and lc.is_active=1 join m_loan loa [...]
\ No newline at end of file
+insert into m_loan_charge_paid_by (`loan_transaction_id`,`loan_charge_id`,`amount`) select
lt.id, lc.id,  if(lic.amount is null,lc.amount,lic.amount)  from m_loan_transaction lt join
m_loan_repayment_schedule rs on rs.loan_id = lt.loan_id and rs.duedate = lt.transaction_date
join m_loan_charge lc on lc.loan_id = rs.loan_id and ((lc.due_for_collection_as_of_date >
rs.fromdate and lc.due_for_collection_as_of_date <= rs.duedate) or lc.charge_time_enum
= 8) and lc.is_active=1 join m_loan loa [...]
\ No newline at end of file


Mime
View raw message