FINERACT-2119: Address jobs by name - fix liquibase order for custom modules
This commit is contained in:
committed by
Aleksandar Vidakovic
parent
8b89aaf413
commit
d5d7f7f5a0
+10
-10
@@ -47,10 +47,10 @@ import org.springframework.stereotype.Service;
|
||||
@RequiredArgsConstructor
|
||||
public class TenantDatabaseUpgradeService implements InitializingBean {
|
||||
|
||||
private static final String TENANT_STORE_DB_CONTEXT = "tenant_store_db";
|
||||
private static final String INITIAL_SWITCH_CONTEXT = "initial_switch";
|
||||
private static final String TENANT_DB_CONTEXT = "tenant_db";
|
||||
private static final String CUSTOM_CHANGELOG_CONTEXT = "custom_changelog";
|
||||
public static final String TENANT_STORE_DB_CONTEXT = "tenant_store_db";
|
||||
public static final String INITIAL_SWITCH_CONTEXT = "initial_switch";
|
||||
public static final String TENANT_DB_CONTEXT = "tenant_db";
|
||||
public static final String CUSTOM_CHANGELOG_CONTEXT = "custom_changelog";
|
||||
|
||||
private final TenantDetailsService tenantDetailsService;
|
||||
@Qualifier("hikariTenantDataSource")
|
||||
@@ -144,17 +144,17 @@ public class TenantDatabaseUpgradeService implements InitializingBean {
|
||||
private void upgradeIndividualTenant(FineractPlatformTenant tenant) throws LiquibaseException {
|
||||
log.info("Upgrade for tenant {} has started", tenant.getTenantIdentifier());
|
||||
DataSource tenantDataSource = tenantDataSourceFactory.create(tenant);
|
||||
// 'initial_switch' and 'custom_changelog' contexts should be controlled by the application configuration
|
||||
// settings, and we should not use them to control the script order
|
||||
if (databaseStateVerifier.isFirstLiquibaseMigration(tenantDataSource)) {
|
||||
ExtendedSpringLiquibase liquibase = liquibaseFactory.create(tenantDataSource, TENANT_DB_CONTEXT, INITIAL_SWITCH_CONTEXT,
|
||||
tenant.getTenantIdentifier());
|
||||
ExtendedSpringLiquibase liquibase = liquibaseFactory.create(tenantDataSource, TENANT_DB_CONTEXT, CUSTOM_CHANGELOG_CONTEXT,
|
||||
INITIAL_SWITCH_CONTEXT, tenant.getTenantIdentifier());
|
||||
applyInitialLiquibase(tenantDataSource, liquibase, tenant.getTenantIdentifier(),
|
||||
(ds) -> !databaseStateVerifier.isTenantOnLatestUpgradableVersion(ds));
|
||||
}
|
||||
SpringLiquibase tenantLiquibase = liquibaseFactory.create(tenantDataSource, TENANT_DB_CONTEXT, tenant.getTenantIdentifier());
|
||||
tenantLiquibase.afterPropertiesSet();
|
||||
SpringLiquibase customChangelogLiquibase = liquibaseFactory.create(tenantDataSource, TENANT_DB_CONTEXT, CUSTOM_CHANGELOG_CONTEXT,
|
||||
SpringLiquibase tenantLiquibase = liquibaseFactory.create(tenantDataSource, TENANT_DB_CONTEXT, CUSTOM_CHANGELOG_CONTEXT,
|
||||
tenant.getTenantIdentifier());
|
||||
customChangelogLiquibase.afterPropertiesSet();
|
||||
tenantLiquibase.afterPropertiesSet();
|
||||
log.info("Upgrade for tenant {} has finished", tenant.getTenantIdentifier());
|
||||
}
|
||||
|
||||
|
||||
+12
-10
@@ -18,6 +18,10 @@
|
||||
*/
|
||||
package org.apache.fineract.infrastructure.core;
|
||||
|
||||
import static org.apache.fineract.infrastructure.core.service.migration.TenantDatabaseUpgradeService.CUSTOM_CHANGELOG_CONTEXT;
|
||||
import static org.apache.fineract.infrastructure.core.service.migration.TenantDatabaseUpgradeService.INITIAL_SWITCH_CONTEXT;
|
||||
import static org.apache.fineract.infrastructure.core.service.migration.TenantDatabaseUpgradeService.TENANT_DB_CONTEXT;
|
||||
import static org.apache.fineract.infrastructure.core.service.migration.TenantDatabaseUpgradeService.TENANT_STORE_DB_CONTEXT;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -57,7 +61,6 @@ public class LiquibaseStepDefinitions implements En {
|
||||
private ExtendedSpringLiquibase tenantStoreLiquibase;
|
||||
private ExtendedSpringLiquibase initialTenantLiquibase;
|
||||
private ExtendedSpringLiquibase tenantLiquibase;
|
||||
private ExtendedSpringLiquibase customChangeLogLiquibase;
|
||||
private FineractPlatformTenant defaultTenant;
|
||||
private DataSource tenantStoreDataSource;
|
||||
private TenantDatabaseUpgradeService tenantDatabaseUpgradeService;
|
||||
@@ -127,7 +130,7 @@ public class LiquibaseStepDefinitions implements En {
|
||||
assertThat(executionException).isNotNull();
|
||||
verify(liquibaseFactory).create(eq(tenantStoreDataSource), anyString(), anyString());
|
||||
verify(liquibaseFactory).create(eq(tenantStoreDataSource), anyString());
|
||||
verify(liquibaseFactory).create(eq(defaultTenantDataSource), anyString(), anyString(), anyString());
|
||||
verify(liquibaseFactory).create(eq(defaultTenantDataSource), anyString(), anyString(), anyString(), anyString());
|
||||
verifyNoMoreInteractions(liquibaseFactory);
|
||||
verify(initialTenantStoreLiquibase).changeLogSync();
|
||||
verify(tenantStoreLiquibase).afterPropertiesSet();
|
||||
@@ -166,7 +169,6 @@ public class LiquibaseStepDefinitions implements En {
|
||||
|
||||
initialTenantLiquibase = mock(ExtendedSpringLiquibase.class);
|
||||
tenantLiquibase = mock(ExtendedSpringLiquibase.class);
|
||||
customChangeLogLiquibase = mock(ExtendedSpringLiquibase.class);
|
||||
initialTenantStoreLiquibase = mock(ExtendedSpringLiquibase.class);
|
||||
tenantStoreLiquibase = mock(ExtendedSpringLiquibase.class);
|
||||
|
||||
@@ -175,16 +177,16 @@ public class LiquibaseStepDefinitions implements En {
|
||||
TenantPasswordEncryptionTask tenantPasswordEncryptor = mock(TenantPasswordEncryptionTask.class);
|
||||
|
||||
given(databaseStateVerifier.isLiquibaseDisabled()).willReturn(!liquibaseEnabled);
|
||||
given(liquibaseFactory.create(tenantStoreDataSource, "tenant_store_db", "initial_switch")).willReturn(initialTenantStoreLiquibase);
|
||||
given(liquibaseFactory.create(tenantStoreDataSource, "tenant_store_db")).willReturn(tenantStoreLiquibase);
|
||||
given(liquibaseFactory.create(tenantStoreDataSource, TENANT_STORE_DB_CONTEXT, INITIAL_SWITCH_CONTEXT))
|
||||
.willReturn(initialTenantStoreLiquibase);
|
||||
given(liquibaseFactory.create(tenantStoreDataSource, TENANT_STORE_DB_CONTEXT)).willReturn(tenantStoreLiquibase);
|
||||
|
||||
given(tenantDetailsService.findAllTenants()).willReturn(allTenants);
|
||||
given(tenantDataSourceFactory.create(defaultTenant)).willReturn(defaultTenantDataSource);
|
||||
given(liquibaseFactory.create(defaultTenantDataSource, "tenant_db", "initial_switch", "defaultTenant"))
|
||||
.willReturn(initialTenantLiquibase);
|
||||
given(liquibaseFactory.create(defaultTenantDataSource, "tenant_db", "defaultTenant")).willReturn(tenantLiquibase);
|
||||
given(liquibaseFactory.create(defaultTenantDataSource, "tenant_db", "custom_changelog", "defaultTenant"))
|
||||
.willReturn(customChangeLogLiquibase);
|
||||
given(liquibaseFactory.create(defaultTenantDataSource, TENANT_DB_CONTEXT, CUSTOM_CHANGELOG_CONTEXT, INITIAL_SWITCH_CONTEXT,
|
||||
"defaultTenant")).willReturn(initialTenantLiquibase);
|
||||
given(liquibaseFactory.create(defaultTenantDataSource, TENANT_DB_CONTEXT, CUSTOM_CHANGELOG_CONTEXT, "defaultTenant"))
|
||||
.willReturn(tenantLiquibase);
|
||||
|
||||
tenantDatabaseUpgradeService = new TenantDatabaseUpgradeService(tenantDetailsService, tenantStoreDataSource, fineractProperties,
|
||||
databaseStateVerifier, liquibaseFactory, tenantDataSourceFactory, environment, Arrays.asList(tenantPasswordEncryptor));
|
||||
|
||||
Reference in New Issue
Block a user