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 migration script filename as a default placeholder #2914

Closed
OliverDTM opened this issue Aug 28, 2020 · 3 comments
Closed

SQL migration script filename as a default placeholder #2914

OliverDTM opened this issue Aug 28, 2020 · 3 comments

Comments

@OliverDTM
Copy link

OliverDTM commented Aug 28, 2020

Which version and edition of Flyway are you using?

Flyway Community Edition 6.3.2

If this is not the latest version, can you reproduce the issue with the latest one as well?

(Many bugs are fixed in newer releases and upgrading will often resolve the issue)
This is not a bug but a change request

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin)

Command-line

Which database are you using (type & version)?

Oracle 18c

Which operating system are you using?

Flyway: Windows 10 / Oracle: Linux

What did you do?

(Please include the content causing the issue, any relevant configuration settings, the SQL statement that failed (if relevant) and the command you ran.)

Is there a kind of default placeholder (like ${flyway:defaultSchema} or ${flyway:timestamp} for example) that is populated by flyway with the current sql migration script name before each migration run?
I want to use the file name with the help of a placeholder in a sql statement (for internal audit processes - the file name of a migration script contains, among other things, an internal ticket number) of a callback script (beforeMigrate or beforeEachMigrate) which, in order to be able to assign it (for internal audit processes), is placed within the same session as the actual migration script (which is the case with callback scripts, as far as I know).
Adjusting the sql migration script name manually in a custom placeholder inside the configfile (as a workaround) before each execution is quite cumbersome.

What did you expect to see?

As I learned with Stack Overflow, there is no such default placeholder. I would like to see this feature in a future flyway version.

What did you see instead?

This is not a bug but a change request

@OliverDTM OliverDTM changed the title SQL Migration Skript Filename as a default placeholder SQL migration script filename as a default placeholder Aug 28, 2020
@MikielAgutu MikielAgutu added this to the On the Radar milestone Sep 30, 2020
@OliverDTM
Copy link
Author

Many thanks for the implementation. But if I use ${flyway:filename} in a callback script (for example beforeEachMigrate), I get the filename of the callback script. But what I need is the filename of the migration script also in the callback script (or the last migration script name in case of afterEachMigrate). Is it also possible to implement this?
I also noticed that the file names are not completely specified by the placeholder (missing double underscores, missing callback filename prefix). Is this intended?

@DoodleBobBuffPants
Copy link
Contributor

...what I need is the filename of the migration script also in the callback script (or the last migration script name in case of afterEachMigrate). Is it also possible to implement this?

This isn't possible as each callback is only parsed, and therefore has its placeholders replaced, once. Parsing it again for each migration in order to identify and replace placeholders would be costly as the number of migrations goes up. It also doesn't feel like it should be a default placeholder for such a singular use case

I also noticed that the file names are not completely specified by the placeholder (missing double underscores, missing callback filename prefix). Is this intended?

This was intended, however it makes sense that a filename placeholder includes the entire filename as opposed to just the migration description

@OliverDTM
Copy link
Author

Thanks for the feedback and the description of the parsing problem. I may have a very special use case... - but the newly implemented placeholder will definitely help me a little bit.
I don't mind the missing part of the filename.
Kind Regards Oliver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants