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 tasks do not use scope specific settings #763
Comments
I haven't tried this, and it's a wild guess, but can you try using lower-case flywayUrl in test := "jdbc:h2:file:target/testbar"
flywayLocations in test := Seq("filesystem:conf/db/migrations/main", "filesystem:conf/db/migrations/test") |
@cdedie Thoughts? |
The test scope is currently not supported by the flyway-sbt plugin. |
+1 for this. Big boon for SBT users |
+1 |
Fixed. Thanks @cdedie ! |
I'm not sure if I am doing this correctly, but can't figure out how to use a different scope. With the // build.sbt
lazy val api = Project.project.in(file("api")).
// ...
settings(flywaySettings: _*).
settings(
// ...
flywayUrl in IntegrationTest := "jdbc:postgresql://localhost:5432/mydb_test"
flywayUser in IntegrationTest := "user"
flywayPassword in IntegrationTest := "pw"
) Then in sbt: > api/it:flywayUrl
[info] jdbc:postgresql://localhost:5432/mydb_test
> api/it:flywayUser
[info] user
> api/it:flywayPassword
[info] pw
> api/it:flywayMigrate
// ...
[info] Flyway 3.2.1 by Boxfuse
[trace] Stack trace suppressed: run last api/*:flywayMigrate for the full output.
[error] (api/*:flywayMigrate) org.flywaydb.core.api.FlywayException: Unable to connect to the database. Configure the url, user and password!
[error] Total time: 3 s, completed 27-Jan-2016 1:33:08 PM
|
Sorry, I see #891 isn't in the current release. |
Is there a snapshot version of flyway available with this fix in it somewhere? |
+1 for an intermediate release to consume this. I am the original reporter of the issue 19 months ago. |
@diwalak I tried to compile the version in master, but it doesn't appear to fix this issue. $ git clone git@github.com/flyway/flyway
$ cd flyway
$ mvn install -P-CommercialDBTest -P-CommandlinePlatformAssemblies -DskipTests=true
$ cd flyway-sbt
$ sbt publish-local // plugins.sbt
resolvers += "Local Maven" at Path.userHome.asFile.toURI.toURL + ".m2/repository"
addSbtPlugin("org.flywaydb" % "flyway-sbt" % "0-SNAPSHOT", "0.13", "2.10") // build.sbt
lazy val api = Project.project.in(file("api")).
// ...
enablePlugins(FlywayPlugin).
configs(IntegrationTest).
settings(Defaults.itSettings: _*).
settings(
// ...
flywayUrl in IntegrationTest := "jdbc:postgresql://localhost:5432/mydb_test"
flywayUser in IntegrationTest := "user"
flywayPassword in IntegrationTest := "pw"
),
(test in IntegrationTest) <<= (test in IntegrationTest) dependsOn flywayMigrate, Unfortunately, I still get exactly the same error: > api/it:flywayUrl
[info] jdbc:postgresql://localhost:5432/mydb_test
> api/it:flywayUser
[info] user
> api/it:flywayPassword
[info] pw
> api/it:flywayMigrate
//...
[info] Flyway 0-SNAPSHOT by Boxfuse
[error] (api/*:flywayMigrate) org.flywaydb.core.api.FlywayException: Unable to connect to the database. Configure the url, user and password!
[error] Total time: 26 s, completed 31-Jan-2016 3:10:55 PM @axelfontaine & @cdedie Unless I'm doing something wrong, should this issue be re-opened? I think the problem is not fixed. |
@cdedie Thoughts? |
@axelfontaine I can invest some time in trying to figure this out, but it will take me some time to get up-to-speed on how to write sbt plugins---unless @cdedie has a quick fix. The problem seems to be that |
@axelfontaine I believe that the current implementation in master is correct. This appears to be the magic sbt incantation to execute tasks in a different Configuration scope: // Copy the flywaySettings into the IntegrationTest configuration.
settings(inConfig(IntegrationTest)(flywaySettings): _*). With that set, I can run either |
What is the way in Flyway 4.0 to do this? By default, only default and
Results in:
|
Hello,
Firstly, thanks for this excellent library. I am really enjoying the compactness and direct SQL-access.
I am trying to use the sbt plugin with a play application. I would like to use different databases for dev and test. I have overridden the
flywayUrl
in theTest
scope. But thetest:flywayMigrate
task still uses theflywayUrl
setting value and not thetest:flywayUrl
setting value.I have a sample app - https://github.com/diwa/flyway_play_test to reproduce the problem
The following is the configuration extract from build.sbt
SBT session
Global settings are recognized
Test Scope settings are recognized
flywayInfo Task does not use test scope settings (see database)
Normal migration works
Test Scope migration does not work (nothing found to migrate)
Can you please help with this as it is essential to have different dbs for dev and test ?
@jsuereth - Am I doing something wrong in the sbt settings for scopes here ?
Thanks in advance for all your support.
The text was updated successfully, but these errors were encountered: