Feng Lei
Feng Lei

Reputation: 19

Possibility for Flyway to split V1__*.sql file into multi files like V1__1.sql, V1__2.sql

I need to set up a new database with more than 50 tables, naturally, they can be divided into several groups:

  1. Group1 for some tables with common data.
  2. Group2 for tables that express one same domain context.
  3. Group3 for tables that express another same domain context.

Each group will be described as a separate SQL file and should be executed following the above order. Since it is the very beginning of initiating a database, I should version them all to V1.

It is something like this:

Or with a directory named V1:

V1/

group1.sql
group2.sql
group3.sql

They are all versioned by V1, group1.sql will be executed before group2.sql and group2.sql will be executed before group3.sql.

With Flyway, can I get this achieved?

Upvotes: 0

Views: 1051

Answers (1)

madninja
madninja

Reputation: 126

There are a number of ways to achieve this.

It is worth noting as well, that there is no technical reason to keep the database setup to version 1; While the names like V1__ and V2__ sound like they mean "version 1" and "version 2", that's not quite true. It is actually the concatenation of two things, the type of script (versioned) and then the sequence number (not the version number); V1 is the first versioned script, V2 is the second versioned script. Scripts will be run in the order defined by their version number.

Upvotes: 3

Related Questions