quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.77k stars 2.68k forks source link

Flyway migrations at test #4232

Open gintsgints opened 5 years ago

gintsgints commented 5 years ago

I would like to have flyway migrations run at test time. So I configure:

# To allow import.sql script with data
%test.quarkus.hibernate-orm.database.generation=update
%test.quarkus.hibernate-orm.sql-load-script = import.sql
# To allow flyway migrations to be run
%test.quarkus.flyway.migrate-at-start=true

Flyway is running after orm database generation and gives error on empty database.

What one could do, so Flyway runs before any hibernate updates?

machi1990 commented 5 years ago

Hi @gintsgints do you have a sample project so that I can have a look? My intuition tells me that you'll need to set an initial base-line using by adding the following config property

%test.quarkus.flyway.baseline-on-migrate=true
gintsgints commented 5 years ago

Here is my example project:

https://github.com/gintsgints/quarkus-ws

viniciusfcf commented 4 years ago

@gintsgints and @gsmet I'm doing some tests using Flyway too. Is it a good idea flyway property "clean-and-migrate-at-start" or quarkus.flyway.clean-at-start to this situation?

With this property, I can use in all profiles:

  1. quarkus.hibernate-orm.database.generation = none
  2. quarkus.hibernate-orm.sql-load-script = no-file

To create a load script per profile instead of quarkus.hibernate-orm.sql-load-script:

%test.quarkus.flyway.locations=db/prod/migration (Versioneds migrations), db/test/migration (test repeatable migration)