golang-migrate / migrate

Database migrations. CLI and Golang library.
Other
14.95k stars 1.37k forks source link

Automatically enable multiStatements for MySQL migrations #185

Open mcandre opened 5 years ago

mcandre commented 5 years ago

Is your feature request related to a problem? Please describe.

Migrations commonly feature multiple statements, yet MySQL connections report parse errors by default.

Describe the solution you'd like

Would it be possible for golang-migrate to automatically enable multiStatements, so that migrations behave better out of the box?

Describe alternatives you've considered

Remembering to explicitly configure multiStatements=true in the fragment of all MySQL connection URLs.

dhui commented 5 years ago

We're using the default value from go-sql-driver/mysql. Changing the default value of a config variable is a breaking change. It's safer to update the docs.

dhui commented 5 years ago

NVM, I stand corrected. The MySQL db driver has always been setting multiStatements to true when using Open(). However, if you use WithInstance(), you'll need to specify multiStatements=true in the DSN passed to sql.Open(). IDK, off the top of my head, of a way to ensure that multiStatements=true is used with sql.Open()