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
MySQL flywayMigrate fails due to user permission #793
Comments
The truth is, it doesn't. It only accesses the DB with the URL, user and password you provide. It opens two connections (one for Flyway itself, and one for the migrations), nothing more. What does your config look like? Also what does the debug output look like? |
gradle debug log is below.
Build machine config
DB machine config
build.gradle (flyway code snippet): Related debug log running "gradle flywayMigrate": |
I think I found the root cause, the flyway code has a "weird hack” (quote directly from flyway source code, see below). Essentially, after db migration scripts are run, successful or not, the flyway code checks if default schema is empty (I believe JDBC String contains the default schema). If empty, then create a new database with random UUID string, then drop that database. This action is causing flywayMigrate to fail with error. Code excerpt from org.flywaydb.core.internal.dbsupport.mysql.MySQLDbSupport in flyway 3.0 library:
The workaround could be in JDBC connection string add default database name. |
Hi Wilkin, Thanks for investigating this. You must have a connection with no schema selected and indeed be hitting this workaround. I have now replaced the error with a warning. As a workaround, you can also make sure your Jdbc url contains a database. Cheers |
Setup: MySQL 5.6 + Gradle + flyway 3.0
When running flywayMigrate, after all db scripts are run successfully, flyway tries to access a new database with UUID. Because the user does not have access to db name=UUID, MySQL denies access, and flywayMigrate fails.
db scripts are run successfully -- after the command is run, I check schema_version table the scripts are defined in that table, and the status flag shows success.
My question: Why would flywayMigrate access database name UUID ? This looks like a bug to me.
:common:flywayMigrate FAILED
FAILURE: Build failed with an exception.
Execution failed for task ':common:flywayMigrate'.
The text was updated successfully, but these errors were encountered: