Open astephensen opened 7 months ago
Thanks for taking a stab at this, @astephensen 🙂
I had to run prettier across a lot of files that I didn't touch — not sure if this was missed in a previous PR or if I didn't have it configured correctly locally, but it was causing the tests to fail.
I think you must have it misconfigured (older prettier version?) - use yarn && yarn lint:fix
to fix formatting issues.
Thanks for the review @benjie, I will address those comments!
Description
This PR will wrap included files with comments, as first described in https://github.com/graphile/migrate/issues/208.
This also facilitates removing the included content when performing an uncommit.
Have opened as a draft as I'm open to any and all feedback!
Pre-Commit
current.sql
fixtures/functions/hello.sql
Committed
migrations/000001-world.sql
Uncommitted
current.sql
Implementation
The method I implemented is similar to what @jcgsville described in the original issue, with a few little changes.
--! Include:
being treated as an actual header if the first statement was an include. Figured dropping the colon helps distinguish this as a file include, but I'm open to suggestions on how to fix this!--! EndIncluded
— This allows a simple regex back reference to be used to delete the included file (if the filename wasn't added, nested includes could be trickier to remove).The main downside of this approach is the original formatting of the
--!include
is not preseved, i.e. if the include is written as--! include ...
the migration will not restore the additional whitespace when uncommitting.Notes
Performance impact
unknown - likely minimal.
Security impact
unknown - likely none.
Checklist
yarn lint:fix
passes.yarn test
passes.RELEASE_NOTES.md
file (if one exists).~ - Does not exist