Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
MySQL: Reset SQL_SAFE_UPDATES and FOREIGN_KEY_CHECKS after each migration #2341
(Sorry if this isn't the right place for feature requests.)
We use Flyway 3.0 for running migrations against our MySQL database. Sometimes our migrations leave the database connection/session in a weird state (such as turning on safe mode). We have noticed that if flyway runs multiple migrations, it runs them all in the same connection/session, and weird state from a past migration can cause future migrations to fail. However, if we run those migrations in separate invocations of flyway, then everything is fine, because flyway creates a fresh connection to the database.
#1250 is a very similar issue, which was fixed in 7aec656 by having flyway track the original value of
What is your exact use case? Is it just
Regarding having a separate connection per migration:
Short story: it's not as trivial as it seems
Long story: For certain databases like SQL Server this wouldn't be possible as certain commands expect no other connection to be active. That being said I am not aware of any similar restrictions for MySQL. But even if we could manage that, we would still have to deal with connection pools intercepting the
Re: SQL Server, I don't think I see why creating a new connection for each migration would cause simultaneous connections?