Check for pending Django migrations

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

    1.10 release notes:

    The new makemigrations --check option makes the command exit with a non-zero status when model changes without migrations are detected.

    If you don't want to create the migrations, combine it with --dry-run:

    python manage.py makemigrations --check --dry-run
    

    Note that this doesn't check whether the migrations were applied, it only checks whether the migration files were created.

提交回复
热议问题