migrate icon indicating copy to clipboard operation
migrate copied to clipboard

Improve multistatement support for postgres

Open nobbynobbs opened this issue 1 year ago • 3 comments

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

nobbynobbs avatar Dec 22 '23 14:12 nobbynobbs

Coverage Status

coverage: 59.56% (+0.4%) from 59.21% when pulling d84929031ed5a2d4a4c7c96212dae67210a20812 on nobbynobbs:improve-postgres-multistatement into 0815e2d770003b4945a4bf86850fb92ca4b7cc5e on golang-migrate:master.

coveralls avatar Dec 22 '23 15:12 coveralls

just hoping/looking forward to getting this merged asap!

bnkamalesh avatar Mar 20 '24 07:03 bnkamalesh

hello @dhui would this PR be considered?

bnkamalesh avatar Apr 15 '24 15:04 bnkamalesh