Database schema migration configuration parameters not working as expected
See original GitHub issueDescribe the bug
Following https://www.keycloak.org/docs/latest/upgrading/index.html it states that you can enable manual schema migration by adding the --spi-connections-jpa-default-migration-strategy=manual parameter
to the startup command.
However when doing so the expected sql file is not generated and database is migrated automatically.
Steps to reproduce the issue
services:
keycloak:
container_name: keycloak
image: quay.io/keycloak/keycloak:15.0.0
environment:
- DB_ADDR=postgres
- DB_USER=keycloak
- DB_PASSWORD=keycloak-secret
ports:
- 8080:8080
- 8443:8443
- 9990:9990
depends_on:
- postgres
postgres:
image: postgres:13-alpine
environment:
- POSTGRES_DB=keycloak
- POSTGRES_USER=keycloak
- POSTGRES_PASSWORD=keycloak-secret
ports:
- 5432:5432
volumes:
- pg-volume:/var/lib/postgresql/data
volumes:
pg-volume:
driver: local
Run docker-compose up and wait for the database to have been setup. Close the instance and create a new docker-compose file with
services:
keycloak:
container_name: keycloak
image: quay.io/keycloak/keycloak:17.0.0
command: ["start", "--auto-build", "--spi-connections-jpa-default-migration-strategy=manual"]
environment:
- KC_DB=postgres
- KC_DB_URL_HOST=postgres
- KC_DB_URL_DATABASE=keycloak
- KC_DB_USERNAME=keycloak
- KC_DB_SCHEMA=public
- KC_DB_PASSWORD=keycloak-secret
ports:
- 8080:8080
- 8443:8443
- 9990:9990
depends_on:
- postgres
postgres:
image: postgres:13-alpine
environment:
- POSTGRES_DB=keycloak
- POSTGRES_USER=keycloak
- POSTGRES_PASSWORD=keycloak-secret
ports:
- 5432:5432
volumes:
- pg-volume:/var/lib/postgresql/data
volumes:
pg-volume:
driver: local
Run docker-compose up again.
Version
17.0.0 Quarkus
Expected behavior
A sql file is generated instead of migrating the database automatically
Actual behavior
The database is migrated automatically
How to Reproduce?
No response
Anything else?
No response
Issue Analytics
- State:
- Created a year ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Troubleshooting the Database Migration - Oracle Help Center
This chapter provides troubleshooting information for the migration of the database from the Sun Java System Content Delivery Server, version 2005Q4 to the ......
Read more >Spring Boot + Hibernate + Flyway: don't run migrations on new ...
I'm using Flyway to update the DB schema. Currently, the latest version of the schema is 3 (the latest migration file is named...
Read more >Troubleshooting migration tasks in AWS Database Migration ...
Check if the object you want to migrate is a table. If it is a view, update table mappings and specify the object-locator...
Read more >Migration failed for TN data (upgrade from 9.10 to 10.5)
Failed migrations Trading Networks data and configuration file ... We do not have any issues while running DCC for TN and TNA database....
Read more >Migrating Room databases | Android Developers
Learn to migrate databases safely using the Room Library. ... Automatic migrations work for most basic schema changes, but you might need to...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@lmorocz Created https://github.com/keycloak/keycloak-documentation/pull/1647 to update docs.
Hi! According to PR#11110 I tried to start v19.0.1 with the manual strategy using parameters:
but unfortunately it didn’t work. The database is migrated automatically and there is no export file in /tmp.
What is missing here?
In 19.0.0 there was a change in the provider id/name from
quarkus
tolegacy
(as well asQuarkusJpaConnectionProviderFactory
->LegacyJpaConnectionProviderFactory
). What is the new provider id/name if I’m usingdb=postgres
?Update
Ok, I checked the “Provider info” page of the master realm and in v19.0.1 with
db=postgres
the SPI is ‘connectionsJpa’ and the provider id islegacy
, so with this setup one should start withbut it depends on the
<provider-id>
. We should update the upgrading documentation and PR#11110 too.