Check for pending Django migrations

前端 未结 8 2279
孤独总比滥情好
孤独总比滥情好 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:27

    ./manage.py showmigrations #check which already-made migrations have been applied or not
    (or: ./manage.py showmigrations someApp #for specific app alone)

    ./manage.py makemigrations --dry-run #check for migrations to be made
    (or: ./manage.py makemigrations someApp --dry-run #for specific app alone)

    ./manage.py makemigrations #make the migrations
    (or: ./manage.py makemigrations someApp #for specific app alone)

    ./manage.py showmigrations #check which already-made migrations have been applied or not
    (or: ./manage.py showmigrations someApp #for specific app alone)

    ./manage.py sqlmigrate someApp 0001 #view SQL changes for specific app & migration

    ./manage.py migrate #apply migrations
    (or: ./manage.py migrate someApp #for specific app alone)

    ./manage.py showmigrations #check which already-made migrations have been applied or not
    (or: ./manage.py showmigrations someApp #for specific app alone)

    ./manage.py makemigrations --dry-run #check for migrations to be made
    (or: ./manage.py makemigrations someApp --dry-run #for specific app alone)

    PS:
    ./manage.py migrate someApp zero #unapply all migrations for specific app

提交回复
热议问题