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

Comments

@voronaam
Copy link

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

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

@voronaam
Copy link
Author

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.

@voronaam
Copy link
Author

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

@MikielAgutu
Copy link

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.

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
Development

No branches or pull requests

3 participants