Allow current.sql to be split into several files
See original GitHub issueHello,
After working for more than 1 month with graphile migrate, I would like to be able to split a big current.sql
into several files smaller files. In practice, it’s actually more useful than named commits as I initially requested in #28.
During the initial development phase of a project, we don’t want to commit/track migrations. Our schema changes a lot, so we don’t want to start building a messy migration history. We’d rather share a big current.sql
between the development team, and commit a clean initial migration when our schema is stable.
Also during that time, we don’t release anything on a production/public environment. We’d rather enjoy the flexibility of being able to reset the database (+run the seeds) every time current.sql
changes.
It works great so far, except for the fact that current.sql
grew to more than 2k lines, which is not great for readability. It would be useful to be able to split current
into smaller files. For instance custom_1_utils.sql
, current_2_create_user.sql
, current_3_mutations.sql
, etc.
This feature is much needed for us so I plan to work on it. If you feel it’s too specific or beyond the scope of migrate I will just make a fork. But if you’re interested in a PR, here’s how I see the specs:
- Automatically detect between a single or multiple
current
files, do not allow both; - Not breaking, optional addition;
- Filename for split current is
current_[int]_[description].sql
; [int]
defines the order in which the sql files are run (doesn’t have to be sequential, but must be >= 1 and unique)[description]
is just a text without any implication;- On commit, it merges all
current_
files into a single sql commit. The commit file is formated in such way that it’s possible to re-create allcurrent_
files onuncommit
.
I didn’t think too much about the format of the commit. It definitely needs to be specific enough so it doesn’t clash with a user’s own comments. For instance:
--! Previous:
--! Hash:
--! Merged:
--! 1: utils
--! 2: users
--! Part: 1 - utils
...
--! Part: 2 - users
...
Let me know what you think. Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (5 by maintainers)
current/
folder, split on--! split
, just numbers, names optional.fwiw, I wrote a small script for this: