Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL Callbacks - more than one .sql file per event #1315

KevinSheedy opened this issue May 19, 2016 · 7 comments

SQL Callbacks - more than one .sql file per event #1315

KevinSheedy opened this issue May 19, 2016 · 7 comments


Copy link

What version of Flyway are you using?


What database are you using (type & version)?

Oracle 11.2

What operating system are you using?

Windows 7 & RHEL

Feature Request

At present, a Sql Callback can execute only one .sql file eg afterMigrate.sql. This file can't import code from another .sql files or 'call' another .sql file. I would like to execute multiple .sql files in a callback.

At present, I use Oracle SqlPlus to execute a list of files after migration but I would prefer if I could do this with Flyway.

Suggested implementation:

Have flyway scan for callback files named something like this: afterMigrate.sql.list
Execute all the .sql files listed.

# This is a comment

# Execute this file

# Execute another file

# Scan this folder and apply every .sql file
Copy link

+1 on this.

Copy link

Could we make the callback names only be prefixes instead?
So for example you could have multiple "afterMigrate" SQL files. Something like:

  • afterMigrate1__my_first_after_migrate.sql
  • afterMigrate2__my_second_after_migrate.sql

Copy link

jowe commented Jul 4, 2017

There is one additional benefit of having more that one hook:
We often combine different locations directories and right now we can use only 'global' hooks
and not hooks within each location.
(I would prefer the afterMigrate post or prefix together with ordering by numbers.)

Copy link

tinproject commented Jul 13, 2017

It would be nice to have callbacks before and after a specific migration only.
An example of the file name could be: prefixVERSIONseparatorDESCRIPTIONseparatorCALLBACKsuffix, where CALLBACK could be beforeMigrate or afterMigrate.

This could be used to insert test data after schema creation to allow that the next migrations could be run with existing data. For example, having the sql scripts for the migration in an sql location and the callbacks on other location like test, running flyway for migrations only with the sql location and for testing with the sql,test location.

Copy link

@tinproject Multiple locations combined with dotted version numbers (7.1, 8.1, ...) already let you achieve this today.

Copy link

goofy77 commented Aug 3, 2017

@axelfontaine could you explain a little bit more?

@axelfontaine axelfontaine added this to the Flyway 5.1.0 milestone Nov 26, 2017
@axelfontaine axelfontaine changed the title Feature Request - SQL Callbacks - more than one .sql file SQL Callbacks - more than one .sql file per event Mar 1, 2018
axelfontaine pushed a commit to flyway/ that referenced this issue Mar 1, 2018
Copy link

This has now been implemented. Multiple SQL callbacks for the same event are now allowed. They then must have a description and are executed in the order of their description.

Example: beforeRepair__vacuum.sql

dohrayme pushed a commit to dohrayme/flyway that referenced this issue Feb 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

7 participants