Support multiple --migrations-dir
directories, merging their contents
#424
Closed
dossy
started this conversation in
Feature Ideas
Replies: 2 comments
-
For anyone who is interested in this, and wants to help test: |
Beta Was this translation helpful? Give feedback.
0 replies
-
This feature is merged now, great work! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It would be great if I could specify multiple
--migrations-dir
(-d
) arguments in an execution, and have dbmate read the migrations files from all of the directories and interleave (merge + sort) the files together, and apply them in the newly sorted order.There are two very distinct use cases I want this functionality for:
1. Schema migrations separate from seed (test) data
In the simplest scenario, I want to keep schema migrations (DDL) in
db/migrations
, and only apply those into my production environment. However, for my dev/test environments, I want to load seed (test) data.I could duplicate everything in
db/migrations
into adb/seeds
, and then have my seed data files mixed in chronologically where they belong. This duplication of file artifacts isn't ideal, but it "solves" the problem.A better solution would be only keeping the common migrations in
db/migrations
and only the seed files indb/seeds
, and then running dbmate with--migrations-dir db/migrations
against production, and--migrations-dir db/migrations --migrations-dir db/seeds
in dev/test, and have dbmate merge the contents of the two directories together before applying them.Note: This isn't just concatenating the list of files in the second specified directory onto the end of the list of files in the first specified directory. This is interleaving them together based on the filenames, sorting them into one single list.
2. Common migrations across environments, with environment-specific additions
Similar to the first scenario above, perhaps I have a shared set of migrations which I want to store in
db/migrations
, but then have special migrations for dev indb/migrations/dev
and for testing indb/migrations/test
, etc. Being able to specify multiple--migrations-dir
locations and having dbmate merge and the contents and applying them.Note: This isn't just about being able to specify only two
--migrations-dir
locations, but two or more, and having them all merged and sorted together.This is functionality I need, personally, so I plan on working on implementing this, but I'd like to know if anyone else is similarly interested in such a feature, and discuss any potential issues or gotchas with the feature as I've envisioned it.
Beta Was this translation helpful? Give feedback.
All reactions