Search code examples
pythongitalembic

alembic revision - multiple heads (due branching) error


I've got an application and I wanted to create a new migration for it today. When I run

$ alembic revision -m "__name__"

I got a message

Only a single head is supported. The script directory has multiple heads (due branching), which must be resolved by manually editing the revision files to form a linear sequence. 
Run `alembic branches` to see the divergence(s).

Running

alembic branches

gives nothing

I'm new to alembic. There are 2 developers working on this app and we have 2 git branches - master & develop (I'm not sure if this have anything to do with it).

Any clue on what is this about?


Solution

  • I've run

    $ python manage.py db history
    

    And as a result I got

    vagrant@precise64:/vagrant$ python manage.py db history
    
    Rev: 29c319804087 (head)
    Parent: 313837798149
    Path: migrations/versions/29c319804087_.py
    
        empty message
    
        Revision ID: 29c319804087
        Revises: 313837798149
        Create Date: 2014-03-05 21:26:32.538027
    
    Rev: 313837798149
    Parent: 280061454d2a
    Path: migrations/versions/313837798149_.py
    
        empty message
    
        Revision ID: 313837798149
        Revises: 280061454d2a
        Create Date: 2014-01-10 03:19:39.838932
    
    Rev: 280061454d2a
    Parent: None
    Path: migrations/versions/280061454d2a_.py
    
        empty message
    
        Revision ID: 280061454d2a
        Revises: None
        Create Date: 2013-12-08 03:04:55.885033
    
    
    Rev: 2e74f61d3b80 (head)
    Parent: 49501407aec9
    Path: migrations/versions/2e74f61d3b80_o2_lease.py
    
        o2 lease
    
        Revision ID: 2e74f61d3b80
        Revises: 49501407aec9
        Create Date: 2014-02-28 10:38:06.187420
    
    Rev: 49501407aec9
    Parent: None
    Path: migrations/versions/49501407aec9_.py
    
        empty message
    
        Revision ID: 49501407aec9
        Revises: None
        Create Date: 2014-01-22 11:27:08.002187
    

    What you can see here is 2 different branches. One starts from 49501407aec9 and second from 280061454d2a. I moved 49501407aec9 and the following 2e74f61d3b80 out of the /versions directory, run

    $ python manage.py db revision
    

    and it created a new migration file.