Keycloak server fails to start when using different named schema
See original GitHub issueDescribe the bug
Keycloak fails to start with the following error when using a different schema than default ‘public’ when running postgres
2022-05-27 12:55:27,356 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (production) mode 2022-05-27 12:55:27,357 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: org.hibernate.exception.SQLGrammarException: could not extract ResultSet 2022-05-27 12:55:27,359 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: could not extract ResultSet 2022-05-27 12:55:27,359 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: ERROR: relation "migration_model" does not exist Position: 121
Looks like it is searching for table migration_model in the public default schema. The tables exist on the named schema
Version
18.0.0
Expected behavior
Keycloak server to start successfully
Actual behavior
keycloak fails to start with error relation “migration_model” does not exist
How to Reproduce?
Use the following config specifying DB schema and start keycloak bat/sh
Basic settings for running in production. Change accordingly before deploying the server.
Database
The database vendor.
db=postgres
The username of the database user.
db-username=postgres
The password of the database user.
db-password=postgres
db-schema=kc
The full database JDBC URL. If not provided, a default URL is set based on the selected database vendor.
db-url=jdbc:postgresql://localhost:5432/kcnew?ssl=false
Anything else?
No response
Issue Analytics
- State:
- Created a year ago
- Comments:6 (5 by maintainers)
FWIW: a possible workaround can be to append the query parameter
currentSchema=kc
to the JDBC url. This is what helped at one of my customers. Just to leave this here in case anybody else stumble over it until it is fixed in the next release.@pedroigor The
currentSchema
Query parameter is postgres specific (see here. Other databases may offer a similar option if they are providing a “schema”, apart from only “database”. Different DB vendors are handling this differently, afaik there’s no standard.