0

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:

  1. New branch off of develop (BRANCH 1)
  2. Create migrations in BRANCH 1
  3. Merge BRANCH 1 into develop
  4. The migrations aren't being run because they are not in master
  5. Another new branch off of develop for a different feature (BRANCH 2)
  6. Now, it's impossible to create migrations in BRANCH 2 - I get Target database is not up to date because the head 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.

AdamGold
  • 4,941
  • 4
  • 29
  • 47

1 Answers1

0

I found a temporary solution:

  1. move BRANCH 1 migration file to a different location
  2. Create a new revision.
  3. Return the migration file to the previous location and merge the two using alembic merge.
AdamGold
  • 4,941
  • 4
  • 29
  • 47