migrate
migrate copied to clipboard
Improve multistatement support for postgres
Hi!
I opened this PR because:
multistmt is naive and simply splits by ; so it's incorrectly separating the body of your function
Before open in it, I've found related issue and the couple of staled PR's:
- https://github.com/golang-migrate/migrate/issues/590 - just issue describes the problem
- https://github.com/golang-migrate/migrate/pull/693 - suggests to use meta-language in comments and looks rejected because of "violates the project's principle around the migration content format"
- https://github.com/golang-migrate/migrate/pull/691 - PR about similar, but different problem
In this PR I suggest to complicate Postgres multi-statement parser, but do not implement all the lexer/parser machinery, preserve the same approach that already used, but make it be respectful to dollar quoted string literals.
Also, I've tried another approach, like use third-party library to parse migration and split it to statements. Sounds good, implementation looks pretty, but doesn't work at all, see https://github.com/nobbynobbs/migrate/pull/1
coverage: 59.56% (+0.4%) from 59.21% when pulling d84929031ed5a2d4a4c7c96212dae67210a20812 on nobbynobbs:improve-postgres-multistatement into 0815e2d770003b4945a4bf86850fb92ca4b7cc5e on golang-migrate:master.
just hoping/looking forward to getting this merged asap!
hello @dhui would this PR be considered?