You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently using Spring Boot with liquibase & the embedded-database-spring-test dependency to start up my PostgreSQL DB for my unit tests & everything was working great with very little work on my end until this past week when I had to refactor my database structure & I now have a 2nd schema that needs to be created when the database is initialized during unit tests; so that when my liquibase scripts run, they are able to find schema B and execute the scripts I have. However, I get an error telling me that "schema B does not exist" so my tests all fail (which makes sense since only one schema gets created normally).
I was hoping to find a way to do this without having to use TestContainers dependency directly. Everything I have tried seems to occur too late in the lifecycle.
I attempted adding @Sql("classpath:db/createSchemas.sql") as well as other variations of this with execution phases, but all of them would occur too late.
I have also attempted adding a CREATE SCHEMA IF NOT EXISTS B; into my liquibase scripts with a context of "test" so that the code only gets executed during my unit tests
I saw something online about trying zonky.test.database.postgres.initdb.database-defaults=CREATE SCHEMA A; CREATE SCHEMA B;
There are quite a few other things I have attempted, but none of them seem to work. Sometimes I debate if they didn't work because I was just missing a small piece of the set up that I needed.
To note: my code works when I run my application, so I am pretty confident my Liquibase scripts are set up properly in general. However, when I start up my application I have a docker-compose.yml that contains this & the init-db.sql contains CREATE SCHEMA IF NOT EXISTS A; CREATE SCHEMA IF NOT EXISTS B;
Hi there! :)
I am currently using Spring Boot with liquibase & the embedded-database-spring-test dependency to start up my PostgreSQL DB for my unit tests & everything was working great with very little work on my end until this past week when I had to refactor my database structure & I now have a 2nd schema that needs to be created when the database is initialized during unit tests; so that when my liquibase scripts run, they are able to find schema B and execute the scripts I have. However, I get an error telling me that "schema B does not exist" so my tests all fail (which makes sense since only one schema gets created normally).
I was hoping to find a way to do this without having to use TestContainers dependency directly. Everything I have tried seems to occur too late in the lifecycle.
@Sql("classpath:db/createSchemas.sql")
as well as other variations of this with execution phases, but all of them would occur too late.CREATE SCHEMA IF NOT EXISTS B;
into my liquibase scripts with a context of "test" so that the code only gets executed during my unit testszonky.test.database.postgres.initdb.database-defaults=CREATE SCHEMA A; CREATE SCHEMA B;
There are quite a few other things I have attempted, but none of them seem to work. Sometimes I debate if they didn't work because I was just missing a small piece of the set up that I needed.
To note: my code works when I run my application, so I am pretty confident my Liquibase scripts are set up properly in general. However, when I start up my application I have a docker-compose.yml that contains this & the
init-db.sql
containsCREATE SCHEMA IF NOT EXISTS A; CREATE SCHEMA IF NOT EXISTS B;
Thank you for your time replying. I really appreciate any help that can be provided.
The text was updated successfully, but these errors were encountered: