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

sbt: Allow specifying URL through system properties #694

Closed
fernandoacorreia opened this issue Feb 8, 2014 · 5 comments
Closed

sbt: Allow specifying URL through system properties #694

fernandoacorreia opened this issue Feb 8, 2014 · 5 comments

Comments

@fernandoacorreia
Copy link

As it is documented, the sbt plugin allows specifying some configuration settings through system properties instead of directly in build.sbt. For example:

sbt -Dflyway.user=myUser -Dflyway.schemas=schema1,schema2 -Dflyway.placeholders.keyABC=valXYZ

It would be useful to have official support and documentation for setting flywayUrl through a flyway.url system property. It is common to have different URLs for development, testing and production, and setting them in build.sbt is not convenient.

Currently, issuing this command:

$ sbt -Dflyway.url=jdbc:h2:file:target/foobar -Dflyway.user=SA flywayMigrate

without specifying flywayUrl in build.sbt produces this error:

[error] Reference to undefined setting: 
[error] 
[error]   *:flywayUrl from *:flywayConfigDataSource

For instance, this shell command should be supported:

$ sbt -Dflyway.driver="$DATASOURCE_DRIVER" -Dflyway.url="$DATASOURCE_URL" -Dflyway.user="$DB_USER" -Dflyway.password="$PASSWORD" flywayMigrate

Additionally, it would be useful to document which settings are supported through system properties.

@axelfontaine
Copy link
Contributor

@cdedie Can you have a look into this?

@cdedie
Copy link
Contributor

cdedie commented Feb 12, 2014

I take a look.
Am 12.02.2014 14:46 schrieb "Axel Fontaine" notifications@github.com:

@cdedie https://github.com/cdedie Can you have a look into this?

Reply to this email directly or view it on GitHubhttps://github.com//issues/694#issuecomment-34869656
.

cdedie pushed a commit to cdedie/flyway that referenced this issue Feb 13, 2014
@cdedie
Copy link
Contributor

cdedie commented Feb 14, 2014

Thanks for reporting.
I committed a fix for this issue in (https://github.com/cdedie/flyway).
Should be merged to master soon.

For current release the following workaround might work:

  1. Specify a default flywayUrl within your build.sbt
    flywayUrl := "jdbc:hsqldb:file:target/flyway_sample;shutdown=true"
  2. Override the flywayUrl via -Dflyway.url
  3. You need to specify all datasource relevant parameters as system properties (driver, url, user, password), cause the default values from build.sbt are not picked up if the flyway.url is provided as a system property.

axelfontaine pushed a commit that referenced this issue Feb 14, 2014
fix for #694 Allow specifying URL through system properties
@axelfontaine
Copy link
Contributor

Thanks @cdedie for this fix! Merged.

@fernandoacorreia
Copy link
Author

Thank you @cdedie and @axelfontaine for the fix. I'll be able to properly test it after play-flyway is updated with a new flyway-core release.

As it was pointed out in the pull request, this StackOverflow question will also have to be updated with a new answer after the next version is released.

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