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 use paths relative to flyway.conf location #944
Comments
Thanks for the suggestion. I am not a fan of adding a config property for this. However... This behavior is currently unspecified. We could therefore specify it to be relative to either the current directory or, like you suggest, the directory the config was loaded from. I'll need to put some thought into this as the what the implications are exactly. In your case you can of course also simply put the location need for the command-line tool in the config file and override with the plugin config in the pom. All other proper can stay as is. |
I think that execution from the command line should resolve non-classpath relative paths by using the working directory (not the install directory), and the build tool should use the project root. |
I have successfully used the following wrapper scripts: Unixcygwin=false
case "`uname`" in
CYGWIN*) cygwin=true;;
esac
# resolve links - $0 may be a softlink
PRG="$0"
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`/"$link"
fi
done
# Set the current directory to the installation directory
INSTALLDIR=`dirname "$PRG"`
# Use JAVA_HOME if it is set
if [ -z "$JAVA_HOME" ]; then
JAVA_CMD=java
else
JAVA_CMD=$JAVA_HOME/bin/java
fi
CP="$INSTALLDIR/lib/*:$INSTALLDIR/drivers/*"
if $cygwin; then
CP=$(cygpath -pw "$CP")
fi
"$JAVA_CMD" -cp "$CP" org.flywaydb.commandline.Main $@
# Save the exit code
JAVA_EXIT_CODE=$?
# Exit using the same code returned from Java
exit $JAVA_EXIT_CODE Windows@Echo off
setlocal
@REM Use JAVA_HOME if it is set
if "%JAVA_HOME%"=="" (
set JAVA_CMD=java
) else (
set JAVA_CMD="%JAVA_HOME%\bin\java.exe"
)
%JAVA_CMD% -cp "%~dp0\lib\*;%~dp0\drivers\*" org.flywaydb.commandline.Main %*
@REM Save the exit code
set JAVA_EXIT_CODE=%ERRORLEVEL%
@REM Exit using the same code returned from Java
EXIT /B %JAVA_EXIT_CODE% |
+1 for relative paths. First thing I'm Googling as a brand new user. |
+1 as well |
++: relative paths would be super helpful |
Yes, I agree that it would be helpful to have some way to make references relative to the configuration file itself. I suggest looking at e.g. TypeScript and how it uses Alternately, we could use a variables like |
+1, relative paths would be super |
+1 |
This also should apply to flyway.conf (not just flyway.properties) as well, I want to simply define this:
So that flyway can pickup my sql from Git repo in repo sub-directory where . represents current directory of my project root (i.e., my git repo directory). -- My noob mistake. I got the above to work by changing above to:
|
This has now been implemented for all client:
|
Regarding the maven plugin, other plugins provide a
For my schema unit tests, I would really like to use the original bundled Sorry to bring this 944 up again. I would have loved that the original posters desired behaviour would become the default: relative to the conf file. I think in any case it would still be a good idea to allow the plugin to explicitely change to a |
@lbreuss This is essentially a new feature request. Please file a new issue for that. |
Agree. #1877 |
Right now
locations
defined inflyway.properties
are relative to current working directory. This may be a command line tool location or location ofpom.xml
for Maven plug-in. This makes it very difficult to use singleflyway.properties
to run some set of migrations.Example file structure:
/someproject/migrations/flyway.properties
/someproject/migrations/sql/V1__aaa.sql
/someproject/migrations/sql/V2__bbb.sql
/someproject/pom.mxl
/tools/flyway/flyway.cmd
Right now if I want to run migrations from maven plug-in with option
configFile
I have to setflyway.locations
tomigrations/sql
in it. If I want to use sameflyway.properties
from command line tool I have to explicitly overridelocations
with absolute path to sql file folder.So I suggest to add a boolean option
locationsAreRelativeToConfig
. If it set totrue
then location offlyway.properties
(or another file provided byconfigFile
option) should be used as base directory forlocations
. So for example above it will be possible to setflyway.locations=filesystem:sql
and use
flyway.properties
file both from maven plug-in and command line tool.The text was updated successfully, but these errors were encountered: