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

Allow to specify target migrate version to match the default behavior #2224

Closed
voronaam opened this issue Nov 30, 2018 · 4 comments
Closed

Allow to specify target migrate version to match the default behavior #2224

voronaam opened this issue Nov 30, 2018 · 4 comments

Comments

@voronaam
Copy link

@voronaam voronaam commented Nov 30, 2018

I would like to allow a special value of the -target parameter for the migrate operation to specify exactly the same behaviour as when -target parameter is omitted.

Using command-line interface as an example:

flyway -target=${parameters.version} migrate

We would want parameters.version to come as a configurable parameter from an upstream pipeline. However, there is no value for this parameter to match the default behaviour "migrate to the latest".

The -target already has one special value ("current"). I propose another special value. It could be either of "null", "empty", "latest". When specified, FlywayDB migrate behaviour exactly matches one when the -target parameter is omitted.

I will create a PR for this proposal. This can be as simple as:

diff --git a/flyway-core/src/main/java/org/flywaydb/core/api/configuration/ClassicConfiguration.java b/flyway-core/src/main/java/org/flywaydb/core/api/configuration/ClassicConfiguration.java
index 8039bb1d1..d6472810b 100644
--- a/flyway-core/src/main/java/org/flywaydb/core/api/configuration/ClassicConfiguration.java
+++ b/flyway-core/src/main/java/org/flywaydb/core/api/configuration/ClassicConfiguration.java
@@ -1577,7 +1577,7 @@ public class ClassicConfiguration implements Configuration {
             setIgnoreFutureMigrations(ignoreFutureMigrationsProp);
         }
         String targetProp = props.remove(ConfigUtils.TARGET);
-        if (targetProp != null) {
+        if (targetProp != null && !"null".equalsIgnoreCase(targetProp)) {
             setTarget(MigrationVersion.fromVersion(targetProp));
         }
         Boolean outOfOrderProp = getBooleanProp(props, ConfigUtils.OUT_OF_ORDER);
@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Dec 4, 2018

We will use the special value latest for this. We'll implement this as part of 6.0.

Loading

@voronaam
Copy link
Author

@voronaam voronaam commented Dec 4, 2018

Thank you.

The naming is the hardest part for me. I am not in any way attached to the null value I used in the PR :)

Updated the PR to match the selected value.

Loading

@voronaam
Copy link
Author

@voronaam voronaam commented Jan 15, 2019

I closed the Pull Request - looks like you are going to address the change inside your own team.

Loading

@MikielAgutu
Copy link
Member

@MikielAgutu MikielAgutu commented Aug 2, 2019

Thanks for the feature request. From V6, this will be possible via a new special value latest for the 'target' configuration option. So you could do something like:

flyway -target=latest migrate

The option will also register for other commands (undo, info, etc) also.

Loading

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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants