migrate icon indicating copy to clipboard operation
migrate copied to clipboard

one sql file only can execute one sql

Open wwbb2008 opened this issue 2 years ago • 1 comments

if I write multiple sql in migrate file,this migrate execute failed, SQL has error。 but this sql can be execute succeed in sql client。

wwbb2008 avatar Jun 19 '23 01:06 wwbb2008

@wwbb2008 You should enable multi-statement in the config for the migrator. Add a query parameter to the URL conn string or enable it in the Config struct passed into the migrator constructor. Here is a reference for Postgres as an example: https://github.com/golang-migrate/migrate/blob/691bc773cc0f8492431cefda5396bbc2e4eea63d/database/pgx/README.md?plain=1#L12

https://github.com/golang-migrate/migrate/blob/master/database/postgres/postgres.go#L49

obalunenko avatar Jun 29 '23 10:06 obalunenko