[Feature] Make trigger migration possible #13
Merged
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Use case
I was trying to include a
CREATE FUNCTIONstatement in a migration file, but I kept getting anunterminated dollar-quoted string at or near "$$error. Upon inspection of the code I saw that the library explodes the whole content of the migration file at the semicolons, and the statement was being diced up in multiple parts.Solution
As a workaround I made it explode at the
";\n"sequence, so you can select which semicolons you need to preserve with an innocuous comment.Example
(Source: https://www.postgresql.org/docs/10/static/plpgsql-trigger.html)
PS It's ugly and hacky, but for now it works... Though it should be documented. If you accept this change I'd also like to contribute a small section on tips about writing plain SQL migrations. I've stumbled upon a few more gotchas.