Django Migration is not applying the migration changes

后端 未结 8 705
悲哀的现实
悲哀的现实 2021-02-02 15:41

Using django 1.7.7 I want to use django\'s migration to add or remove a field. so I modified model.py and ran

python manage.py makemigrations myproj
Migrations f         


        
8条回答
  •  面向向阳花
    2021-02-02 16:16

    Similar to Andrew E above but with a few changes especially where you haven't deleted the migrations folder in your quest to resolve the issue

    1 - In your intact migration folder just examine the 000*.py files counting from the highest down to initial.py till you find the one where your Model is defined, say 0002_entry.py

    2 - python manage.py sqlmigrate app-name 0002 > 0002_sql.txt to capture the SQL commands

    3 - Edit this file to ensure there are no hard CR/LFs and the ALTER, CREATE INDEX commands are each on own single line

    4 - Log into your DB (I have Postgres) and run these commands

提交回复
热议问题