migrate icon indicating copy to clipboard operation
migrate copied to clipboard

"Include" comment

Open benjie opened this issue 2 years ago • 0 comments

Feature description

We already have --! no-transaction special comment, and we have :PLACEHOLDER replacement... This feature would replace a --! include funcs/my_func.sql comment with the contents of the funcs/my_func.sql file from the migrations/ folder. This is akin to symlinking the file into the current/ directory, but with the following advantages:

  1. works on Windows :wink:
  2. works with current.sql in addition to current/ folder
  3. easier to view history in git
  4. no need to come up with a numeric prefix for it - can just reorder as text

On commit a snapshot of the file will be included into the migrations/committed/ entry (and this is the code that would run on graphile-migrate migrate, rather than performing the --! include at that time).

Motivating example

Iterating functions, policies, and other stateless resources can be annoying - having to copy the definitions out from a previous migration or from a DB dump and then edit them. Also tracking history of them is a pain. Easier to edit them in one place (like regular code) and then "pull" them into the migration for execution.

Breaking changes

None.

benjie avatar Sep 08 '22 08:09 benjie