My Git flow consists of develop
, master
and feature
branches. I use Alembic for database migrations, and I run migrations only after merging branches into master.
Currently, merging a branch containing migrations into develop
causes trouble. Here is the problematic process:
- New branch off of
develop
(BRANCH 1) - Create migrations in BRANCH 1
- Merge BRANCH 1 into
develop
- The migrations aren't being run because they are not in
master
- Another new branch off of
develop
for a different feature (BRANCH 2) - Now, it's impossible to create migrations in BRANCH 2 - I get
Target database is not up to date
because thehead
revision is the new revision created in #1, but the database has not been upgraded yet.
Running alembic history
gives:
c4892151a825 -> 3451e691af8a (head), BRANCH 1
c4a0d473218e -> c4892151a825, MASTER MIGRATIONS
What I'm trying to achieve is to have the two migrations run sequentially:
c4892151a825 -> 3451e691a4jf BRANCH 2
c4892151a825 -> 3451e691af8a BRANCH 1
... -> c4892151a825, (head), MASTER MIGRATIONS
I tried running alembic revision --head c4892151a825
, but it says that the revision is not a head
revision.