Check for pending Django migrations

前端 未结 8 2076
孤独总比滥情好
孤独总比滥情好 2021-02-01 13:05

In Django, is there an easy way to check whether all database migrations have been run? I\'ve found manage.py migrate --list, which gives me the information I want,

8条回答
  •  无人共我
    2021-02-01 13:25

    Try,

    python manage.py migrate --list | grep "\[ \]\|^[a-z]" | grep "[ ]" -B 1
    

    returns,

    
     [ ] 0001_initial
     [ ] 0002_auto_01201244
     [ ] 0003_auto_12334333
    
    
     [ ] 0031_auto_12344544
     [ ] 0032_auto_45456767
     [ ] 0033_auto_23346566
    
    
     [ ] 0008_auto_3446677
    


    Update:

    If you have updated Django version >= 1.11, use below command,

    python manage.py showmigrations | grep '\[ \]\|^[a-z]' | grep '[  ]' -B 1
    

提交回复
热议问题