Reputation: 31
I have a scenario in which a number of SQL files need to be executed in a given order. The file names are like accounts.sql, contacts.sql, etc. Is there a way we can specify the order (probably in a text file or configuration) so that we can control the sequence? The order is important as the SQL files contain various types of instructions such as creating or altering tables, setting index, creating stored procedures and triggers etc.
Any suggestions on this would be immensely helpful. Thanks in advance.
Upvotes: 2
Views: 673
Reputation: 448
Flyway Teams (the paid edition) provides the cherryPick
option. With cherryPick
migrations are executed in the order specified. See the cherryPick
docs page.
For example, you could run:
flyway migrate -cherryPick=1,3,2,4
To execute migrations in the order V1, V3, V2, and finally V4.
All configuration options can be specified in a Flyway configuration file. Since you can have multiple configuration files, you could create a configuration file dedicated to your cherryPick
ordering. See this docs page.
Also note you'll have to make sure your script files confirm to Flyway's naming conventions.
Upvotes: 2