2014-03-12 5 views
8

플라스크에 응용 프로그램 빌드가 있으며 오늘 새 마이그레이션을 만들고 싶습니다. 내가alembic revision - 멀티 헤드 (만기 분기) 오류

$ alembic revision -m "__name__" 

를 실행하면 나는

alembic branches 

이 & 증류기를 플라스크에 나는 새로운 해요 아무것도

을 제공하지 실행 메시지

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). 

을 얻었다. 이 응용 프로그램에서 일하는 2 명의 개발자가 있습니다. 우리는 2 개의 git 브랜치 (마스터 &)를 개발했습니다 (이 작업이 관련이 있는지는 잘 모르겠습니다).

이것에 대한 단서가 있습니까?

답변

4

나는

$ python manage.py db history 

을 실행 한 결과로 나는

[email protected]:/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 

당신이 여기에서 볼 수있는 것은 2 개 개의 다른 지점이다 얻었다. 하나는 49501407aec9에서 시작하고 두 번째는 280061454d2a에서 시작합니다. 나는

$ python manage.py db revision 

을 실행 49501407aec9하고/버전 디렉토리 중 다음 2e74f61d3b80을 이동하며 새로운 마이그레이션 파일을 만들었습니다.

9

이 문제는 동일한 마이그레이션에서 두 개의 alembic 마이그레이션이 분기 될 때 발생합니다. 대개 이것은 여러 사람이 스키마를 변경하는 경우에 발생합니다. 이 문제를 해결하려면 가장 최근의 마이그레이션이되도록 down_revision을 조정해야합니다. alembic history을 실행하면 우리에게 보여줍니다이 :

2f4682466279 -> f34e92e9dc54 (head), Fifth revision (on a separate branch) 
 
2f4682466279 -> f673ac37b34a (head), Fifth revision (local) 
 
2dc9337c3987 -> 2f4682466279, Fourth revision 
 
0fa2aed0866a -> 2dc9337c3987, Third revision 
 
22af4a75cf06 -> 0fa2aed0866a, Second revision 
 
9a8942e953eb -> 22af4a75cf06, First revision

당신은 다섯 번째 버전 중 하나가 로컬로 만들어 졌다고 볼 수 있으며 하류 개정의 2f4682466279입니다 누구든지 다른 다섯 번째 개정도 같은 다운 스트림 버전을 가지고 만든 .

는 다섯 번째 개정 파일 중 하나에 가서 같이, 다른 다섯 번째 버전을 참조 할 down_revision 변수를 업데이트

f673ac37b34a -> f34e92e9dc54 (head), Fifth revision (on a separate branch) 
 
2f4682466279 -> f673ac37b34a, Fifth revision (local) 
 
2dc9337c3987 -> 2f4682466279, Fourth revision 
 
0fa2aed0866a -> 2dc9337c3987, Third revision 
 
22af4a75cf06 -> 0fa2aed0866a, Second revision 
 
9a8942e953eb -> 22af4a75cf06, First revision

내가 down_revision='f673ac37b34a'을 가지고 마이그레이션 f34e92e9dc54 업데이트이 경우.