Pull request #647: RED-4515: Fixed liquibase migration for tenants
Merge in RED/persistence-service from RED-4515 to master * commit '12bf0d4eda6f7af9e116f2da2c1046a1f469f68a': RED-4515: Fixed liquibase migration for tenants
This commit is contained in:
commit
e53f82e539
@ -52,7 +52,7 @@ public class TenantSpringLiquibaseExecutor implements InitializingBean, Resource
|
|||||||
for (TenantEntity tenant : tenants) {
|
for (TenantEntity tenant : tenants) {
|
||||||
|
|
||||||
log.info("Initializing Liquibase for tenant " + tenant.getTenantId());
|
log.info("Initializing Liquibase for tenant " + tenant.getTenantId());
|
||||||
try (Connection connection = DriverManager.getConnection(JDBCUtils.buildJdbcUrl(tenant.getDatabaseConnection()),
|
try (Connection connection = DriverManager.getConnection(JDBCUtils.buildJdbcUrlWithSchema(tenant.getDatabaseConnection()),
|
||||||
tenant.getDatabaseConnection().getUsername(),
|
tenant.getDatabaseConnection().getUsername(),
|
||||||
encryptionService.decrypt(tenant.getDatabaseConnection().getPassword()))) {
|
encryptionService.decrypt(tenant.getDatabaseConnection().getPassword()))) {
|
||||||
DataSource tenantDataSource = new SingleConnectionDataSource(connection, false);
|
DataSource tenantDataSource = new SingleConnectionDataSource(connection, false);
|
||||||
|
|||||||
@ -61,4 +61,22 @@ public class JDBCUtils {
|
|||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String buildJdbcUrlWithSchema(DatabaseConnectionEntity databaseConnection){
|
||||||
|
StringBuilder sb = new StringBuilder("jdbc:")
|
||||||
|
.append(databaseConnection.getDriver())
|
||||||
|
.append("://")
|
||||||
|
.append(databaseConnection.getHost())
|
||||||
|
.append(':')
|
||||||
|
.append(databaseConnection.getPort())
|
||||||
|
.append('/')
|
||||||
|
.append(databaseConnection.getDatabase())
|
||||||
|
.append('?')
|
||||||
|
.append("currentSchema=")
|
||||||
|
.append(databaseConnection.getSchema());
|
||||||
|
if(databaseConnection.getParams() != null) {
|
||||||
|
databaseConnection.getParams().forEach((k, v) -> sb.append('&').append(k).append(v));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user