Reputation: 19
I need to set up a new database with more than 50 tables, naturally, they can be divided into several groups:
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
Reputation: 126
There are a number of ways to achieve this.
V1__
for group one, v2__
for group two etc.v1.1
for group one, v1.2
for group 2. Flyway is very flexible with its version numbers supporting multiple parts, such as `v1.1.0.68'. See https://flywaydb.org/documentation/concepts/migrations#versioned-migrations for more details.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