FINERACT-1571: Allow Liquibase data migration for write instances only
This commit is contained in:
committed by
Arnold Gálovics
parent
e3e4dbeb8a
commit
56d14a1d69
+4
-6
@@ -21,13 +21,15 @@ package org.apache.fineract.infrastructure.core.service.migration;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import javax.sql.DataSource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.fineract.infrastructure.core.config.FineractProperties;
|
||||
import org.apache.fineract.infrastructure.core.service.database.DatabaseIndependentQueryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties;
|
||||
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class TenantDatabaseStateVerifier {
|
||||
|
||||
private static final int TENANT_STORE_LATEST_FLYWAY_VERSION = 6;
|
||||
@@ -40,11 +42,7 @@ public class TenantDatabaseStateVerifier {
|
||||
private final LiquibaseProperties liquibaseProperties;
|
||||
private final DatabaseIndependentQueryService dbQueryService;
|
||||
|
||||
@Autowired
|
||||
public TenantDatabaseStateVerifier(LiquibaseProperties liquibaseProperties, DatabaseIndependentQueryService dbQueryService) {
|
||||
this.liquibaseProperties = liquibaseProperties;
|
||||
this.dbQueryService = dbQueryService;
|
||||
}
|
||||
private final FineractProperties fineractProperties;
|
||||
|
||||
public boolean isFirstLiquibaseMigration(DataSource dataSource) {
|
||||
boolean databaseChangelogTableExists = dbQueryService.isTablePresent(dataSource, "DATABASECHANGELOG");
|
||||
|
||||
+4
-1
@@ -68,8 +68,11 @@ public class TenantDatabaseUpgradeService implements InitializingBean {
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
if (databaseStateVerifier.isLiquibaseDisabled()) {
|
||||
if (databaseStateVerifier.isLiquibaseDisabled() || !fineractProperties.getMode().isWriteEnabled()) {
|
||||
LOG.warn("Liquibase is disabled. Not upgrading any database.");
|
||||
if (!fineractProperties.getMode().isWriteEnabled()) {
|
||||
LOG.warn("Liquibase is disabled because the current instance is configured as a non-write Fineract instance");
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user