java - How to store Flyway H2 migrations' history in another schema than PUBLIC? -
using flyway h2 database, out of box sql schema migrations history stored in public.schema_version
.
i store table in dedicated sql schema flyway, this: flyway.history
.
reasons doing not pollute h2 console visually when opening public tables, , avoid namespace collision.
by modifying property flyway.table
, name history table can changed.
but using flyway.table=flyway.history
not work. schema flyway not created , table public.'flyway.history'
gets created instead.
how should 1 tweak flyway configuration in order achieve expected result?
providing property solves problem partially: flyway.schemas=flyway,public
.
by doing so, history table stored in schema flyway migrations run default on schema.
please refer http://flywaydb.org/documentation/commandline/migrate.html , schemas more details.
i found 2 issues approach, can fixed minor tweaks.
1st issue:
the schema flyway must existing before flyway migration attempt. can done in java using stmt.execute("create schema if not exists flyway");
, close database before migration
2nd issue:
all migrations run default on schema flyway. can fixed modifying each sql migration file point public schema. each file contain these statements: create table public.person (...);
i've solved problem @ hand, i'm not happy fix , manual work. can come better answer (more native way) , less tweaks.
Comments
Post a Comment