mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-09 23:12:06 -03:30
Use updated PostgresDatabase from Liquibase 4.32.0 (#40530)
Signed-off-by: Martin Bartoš <mabartos@redhat.com>
This commit is contained in:
parent
c01736a9cd
commit
3a7569662e
@ -0,0 +1,54 @@
|
||||
package org.keycloak.connections.jpa.updater.liquibase;
|
||||
|
||||
import liquibase.GlobalConfiguration;
|
||||
import liquibase.database.ObjectQuotingStrategy;
|
||||
import liquibase.database.core.PostgresDatabase;
|
||||
import liquibase.structure.DatabaseObject;
|
||||
import liquibase.structure.core.Catalog;
|
||||
import liquibase.structure.core.Schema;
|
||||
import liquibase.util.StringUtil;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Workaround for <a href="https://github.com/keycloak/keycloak/issues/39917">keycloak#39917</a>
|
||||
* Remove it once Liquibase 4.32.0 is used
|
||||
*/
|
||||
public class UpdatedPostgresDatabase extends PostgresDatabase {
|
||||
|
||||
@Override
|
||||
public int getPriority() {
|
||||
return super.getPriority() + 1; // Always take precedence over factory PostgresDatabase
|
||||
}
|
||||
|
||||
/**
|
||||
* Use updated version present in Liquibase 4.32.0 - <a href="https://github.com/liquibase/liquibase/blob/v4.32.0/liquibase-standard/src/main/java/liquibase/database/core/PostgresDatabase.java#L300">PostgresDatabase.correctObjectName()</a>
|
||||
*/
|
||||
@Override
|
||||
public String correctObjectName(String objectName, Class<? extends DatabaseObject> objectType) {
|
||||
if ((objectName == null) || (quotingStrategy != ObjectQuotingStrategy.LEGACY)) {
|
||||
return super.correctObjectName(objectName, objectType);
|
||||
}
|
||||
//
|
||||
// Check preserve case flag for schema
|
||||
//
|
||||
if (objectType.equals(Schema.class) && Boolean.TRUE.equals(GlobalConfiguration.PRESERVE_SCHEMA_CASE.getCurrentValue())) {
|
||||
return objectName;
|
||||
}
|
||||
|
||||
if (objectType.equals(Catalog.class) && !StringUtil.hasLowerCase(objectName)) {
|
||||
return objectName;
|
||||
}
|
||||
|
||||
if (objectName.contains("-")
|
||||
|| hasMixedCase(objectName)
|
||||
|| startsWithNumeric(objectName)
|
||||
|| isReservedWord(objectName)) {
|
||||
return objectName;
|
||||
} else {
|
||||
return objectName.toLowerCase(Locale.US);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -17,4 +17,5 @@
|
||||
|
||||
org.keycloak.connections.jpa.updater.liquibase.PostgresPlusDatabase
|
||||
org.keycloak.connections.jpa.updater.liquibase.UpdatedMariaDBDatabase
|
||||
org.keycloak.connections.jpa.updater.liquibase.UpdatedMySqlDatabase
|
||||
org.keycloak.connections.jpa.updater.liquibase.UpdatedMySqlDatabase
|
||||
org.keycloak.connections.jpa.updater.liquibase.UpdatedPostgresDatabase
|
||||
@ -210,7 +210,7 @@ public final class Database {
|
||||
getProperty(DatabaseOptions.DB_URL_PORT, namedProperty, "5432"),
|
||||
getProperty(DatabaseOptions.DB_URL_DATABASE, namedProperty, "keycloak"),
|
||||
getProperty(DatabaseOptions.DB_URL_PROPERTIES, namedProperty)),
|
||||
asList("liquibase.database.core.PostgresDatabase", "org.keycloak.connections.jpa.updater.liquibase.PostgresPlusDatabase"),
|
||||
asList("org.keycloak.connections.jpa.updater.liquibase.UpdatedPostgresDatabase", "org.keycloak.connections.jpa.updater.liquibase.PostgresPlusDatabase"),
|
||||
"postgres"
|
||||
),
|
||||
MSSQL("mssql",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user