postgresqlinitializationquarkustestcontainers

Run init script on datasource devservice in quarkus?


I have a Quarkus project that uses a postgresql datasource. In production, we create the necessary schemas on the db manually before.

When I run quarkusDev mode and use the devservices, I therefor would like to run an init script on the testcontainer to create the schemas before liquibase does its migrations, which otherwise will fail.

I tried this without success

quarkus.datasource.jdbc.url=jdbc:tc:postgresql:13:///quarkus?TC_INITSCRIPT=testcontainer/schema-init.sql
quarkus.datasource.jdbc.driver=org.testcontainers.jdbc.ContainerDatabaseDriver

Nothing got picked up by the postgres testcontainer.

How can I run a init script on a datasource testcontainer with quarkus?


Solution

  • As stated here: https://quarkus.io/guides/databases-dev-services#database-vendor-specific-configuration

    specific properties supported by the Testcontainers JDBC driver such as TC_INITSCRIPT, TC_INITFUNCTION, TC_DAEMON, TC_TMPFS are not supported.

    So this simply does not work