Properly setting the database schema (#9400)

Closes #9398
This commit is contained in:
Pedro Igor 2022-01-11 00:22:11 -08:00 committed by GitHub
parent cbfd989ca9
commit b2e55762f1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View file

@ -78,7 +78,7 @@ final class DatabasePropertyMappers {
.isMasked(true) .isMasked(true)
.build(), .build(),
builder().from("db.schema") builder().from("db.schema")
.to("quarkus.datasource.schema") .to("quarkus.hibernate-orm.database.default-schema")
.description("The database schema to be used.") .description("The database schema to be used.")
.paramLabel("schema") .paramLabel("schema")
.build(), .build(),

View file

@ -65,6 +65,7 @@ import org.keycloak.models.dblock.DBLockManager;
import org.keycloak.models.dblock.DBLockProvider; import org.keycloak.models.dblock.DBLockProvider;
import org.keycloak.models.utils.RepresentationToModel; import org.keycloak.models.utils.RepresentationToModel;
import org.keycloak.provider.ServerInfoAwareProviderFactory; import org.keycloak.provider.ServerInfoAwareProviderFactory;
import org.keycloak.quarkus.runtime.configuration.Configuration;
import org.keycloak.representations.idm.RealmRepresentation; import org.keycloak.representations.idm.RealmRepresentation;
import org.keycloak.representations.idm.UserRepresentation; import org.keycloak.representations.idm.UserRepresentation;
import org.keycloak.services.ServicesLogger; import org.keycloak.services.ServicesLogger;
@ -175,7 +176,7 @@ public final class QuarkusJpaConnectionProviderFactory implements JpaConnectionP
@Override @Override
public String getSchema() { public String getSchema() {
return config.get("schema"); return Configuration.getRawValue("kc.db.schema");
} }
@Override @Override

View file

@ -304,6 +304,11 @@ public class ConfigurationTest {
assertEquals("jdbc:postgresql://localhost/keycloak?test=test&test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue()); assertEquals("jdbc:postgresql://localhost/keycloak?test=test&test1=test1", config.getConfigValue("quarkus.datasource.jdbc.url").getValue());
assertEquals(QuarkusPostgreSQL10Dialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue()); assertEquals(QuarkusPostgreSQL10Dialect.class.getName(), config.getConfigValue("quarkus.hibernate-orm.dialect").getValue());
assertEquals(PGXADataSource.class.getName(), config.getConfigValue("quarkus.datasource.jdbc.driver").getValue()); assertEquals(PGXADataSource.class.getName(), config.getConfigValue("quarkus.datasource.jdbc.driver").getValue());
System.setProperty(CLI_ARGS, "--db-schema=test-schema");
config = createConfig();
assertEquals("test-schema", config.getConfigValue("kc.db.schema").getValue());
assertEquals("test-schema", config.getConfigValue("quarkus.hibernate-orm.database.default-schema").getValue());
} }
// KEYCLOAK-15632 // KEYCLOAK-15632