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

**URL:** <https://forum.keycloak.org/t/run-only-liquibase-for-deployment-and-in-a-second-step-the-deployment-of-keycloak-application/26543>\
**Category:** Getting advice\
**Tags:** authentication, oidc\
**Created:** [June 18, 2024, 9:17am UTC](https://forum.keycloak.org/t/run-only-liquibase-for-deployment-and-in-a-second-step-the-deployment-of-keycloak-application/26543 "2024-06-18T09:17:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tania](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/tania/32/9460_2.png) [@tania](https://forum.keycloak.org/u/tania)\
**Post date:** [June 18, 2024, 9:17am UTC](https://forum.keycloak.org/t/run-only-liquibase-for-deployment-and-in-a-second-step-the-deployment-of-keycloak-application/26543/1 "2024-06-18T09:17:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [June 18, 2024, 4:49pm UTC](https://forum.keycloak.org/t/run-only-liquibase-for-deployment-and-in-a-second-step-the-deployment-of-keycloak-application/26543/2 "2024-06-18T16:49:51Z")

</div>

The liquibase migrations are here: [model/jpa/src/main/resources/META-INF/](https://github.com/keycloak/keycloak/tree/main/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.

---

<div class="post-metadata">

**Author:** ![tania](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/tania/32/9460_2.png) [@tania](https://forum.keycloak.org/u/tania)\
**Post date:** [June 19, 2024, 11:53am UTC](https://forum.keycloak.org/t/run-only-liquibase-for-deployment-and-in-a-second-step-the-deployment-of-keycloak-application/26543/3 "2024-06-19T11:53:45Z")

</div>

Thank you very much for your response.

---

<div class="post-metadata">

**Author:** ![tania](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/tania/32/9460_2.png) [@tania](https://forum.keycloak.org/u/tania)\
**Post date:** [June 19, 2024, 1:10pm UTC](https://forum.keycloak.org/t/run-only-liquibase-for-deployment-and-in-a-second-step-the-deployment-of-keycloak-application/26543/4 "2024-06-19T13:10:06Z")

</div>

@xgp Hi, i am trying this [Keycloak Database creation - keycloak-database-update.sql - #2 by ssb](https://forum.keycloak.org/t/keycloak-database-creation-keycloak-database-update-sql/5543/2)  
but i am getting the following error:

```auto
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.
