keycloak: ERROR: relation "migration_model" does not exist
Describe the bug
I’m not 100% sure if this is a bug or a missing configuration from my side. I can’t get the latest Docker image quay.io/keycloak/keycloak:17.0.0 up and running. The start always fails with the follwoing log messages:
2022-02-15 19:54:42,453 WARN [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (main) SQL Error: 0, SQLState: 42P01
2022-02-15 19:54:42,453 ERROR [org.hibernate.engine.jdbc.spi.SqlExceptionHelper] (main) ERROR: relation "migration_model" does not exist
Position: 121
2022-02-15 19:54:42,500 INFO [org.infinispan.CLUSTER] (main) ISPN000080: Disconnecting JGroups channel `ISPN`
2022-02-15 19:54:42,555 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Failed to start server in (production) mode
2022-02-15 19:54:42,555 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
2022-02-15 19:54:42,555 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: could not extract ResultSet
2022-02-15 19:54:42,556 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: ERROR: relation "migration_model" does not exist
Position: 121
Anyone experiencing the same issue? The configuration was working with the jboss/keycloak:16.1.0 image. I also tried to delete and re-create an empty database schema. But no luck either.
Version
17.0.0
Expected behavior
successfull start.
Actual behavior
ERROR: ERROR: relation "migration_model" does not exist
How to Reproduce?
# docker-compose.yml
version: "3.6"
services:
## Keycloak IAM Authentication Provider
authentication-provider:
image: quay.io/keycloak/keycloak:17.0.0
command: "start --auto-build"
ports:
- "9001:8080"
restart: unless-stopped
environment:
## Host settings
KC_HOSTNAME: keycloak
## Database settings
KC_DB: postgres
KC_DB_URL: jdbc:postgresql://${PG_HOST}:${PG_PORT}/${PG_DB}
KC_DB_SCHEMA: ${KEYCLOAK_SCHEMA}
KC_DB_USERNAME: ${PG_USER}
KC_DB_PASSWORD: ${PG_PASSWORD}
## Admin User settings
KEYCLOAK_USER: ${KEYCLOAK_USER}
KEYCLOAK_PASSWORD: ${KEYCLOAK_PASSWORD}
## Proxy settings
KC_PROXY: edge
### Anything else?
_No response_
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 4
- Comments: 25 (4 by maintainers)
Commits related to this issue
- Exposing keycloak/keycloak#10235 — committed to jamesdh/keycloak_startup by jamesdh a year ago
Same issue for me but only when i try to connect to postgresql on Azure , locally works fine. I Resolved it (workaround) by specifying schema name inside KC_DB_SCHEMA and also in KC_DB_URL
ENV KC_DB_URL=jdbc:postgresql://[db_addr]:[db_port]/[db_name]?currentSchema=[db_schema]
The issue miraculously disappeared.
I’m seeing this in version 18, but Keycloak does start. Is this expected?
Hi, your postgresql database is missing a schema search path. Use this sql statement:
This worked for me.
Just encountered the same error after I changed from
--db-urlto using separate env variables on 17.0.0 -> 17.0.0.I kept this workaround since keycloak-x16:
It works because kc.sh in docker evaluates variables
This issue should have been fixed, I think? https://github.com/keycloak/keycloak/issues/9398 https://github.com/keycloak/keycloak/issues/9328