Run only liquibase for deployment and in a second step the deployment of keycloak application

Hi all,
I would like to get an advise on where i will find the liquibase for keycloak database.
I am running the keycloak version 21.1.2 on a docker

I would like to first have the database of keycloak run in a docker image in a production mode and then run the keycloak application. Is there an example on this?

Thank you in advance

The liquibase migrations are here: model/jpa/src/main/resources/META-INF/

I would like to first have the database of keycloak run in a docker image in a production mode and then run the keycloak application. Is there an example on this?

Why don’t you just start up Keycloak? It automatically runs the migration. If you want to do this before you start your Keycloak instances that receive requests, you can. Trying to run those migrations manually, without the full Keycloak will fail, as there is custom migration code referenced in those migration files.

Thank you very much for your response.

@xgp Hi, i am trying this Keycloak Database creation - keycloak-database-update.sql - #2 by ssb
but i am getting the following error:

2024-06-19 13:02:38,689 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: liquibase.exception.MigrationFailedException: Migration failed for changeset META-INF/jpa-changelog-1.0.0.Final.xml::1.0.0.Final-KEYCLOAK-5461::sthorger@redhat.com:
     Reason: liquibase.exception.DatabaseException: Communications link failure

The last packet successfully received from the server was 228 milliseconds ago. The last packet sent successfully to the server was 228 milliseconds ago. [Failed SQL: (0) ALTER TABLE keycloak.REALM_ATTRIBUTE ADD CONSTRAINT FK_8SHXD6L3E9ATQUKACXGPFFPTW FOREIGN KEY (REALM_ID) REFERENCES keycloak.REALM (ID)]
2024-06-19 13:02:38,689 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Migration failed for changeset META-INF/jpa-changelog-1.0.0.Final.xml::1.0.0.Final-KEYCLOAK-5461::sthorger@redhat.com:
     Reason: liquibase.exception.DatabaseException: Communications link failure

The last packet successfully received from the server was 228 milliseconds ago. The last packet sent successfully to the server was 228 milliseconds ago. [Failed SQL: (0) ALTER TABLE keycloak.REALM_ATTRIBUTE ADD CONSTRAINT FK_8SHXD6L3E9ATQUKACXGPFFPTW FOREIGN KEY (REALM_ID) REFERENCES keycloak.REALM (ID)]
2024-06-19 13:02:38,689 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Communications link failure

The last packet successfully received from the server was 228 milliseconds ago. The last packet sent successfully to the server was 228 milliseconds ago. [Failed SQL: (0) ALTER TABLE keycloak.REALM_ATTRIBUTE ADD CONSTRAINT FK_8SHXD6L3E9ATQUKACXGPFFPTW FOREIGN KEY (REALM_ID) REFERENCES keycloak.REALM (ID)]
2024-06-19 13:02:38,689 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: Communications link failure


Is it even possible to make the manual migration even it is documented? This documentation is for version 25 and not the 21.1.2 i am using.