Django migrate : doesn't create tables

前端 未结 10 1705
独厮守ぢ
独厮守ぢ 2021-01-31 18:03

After some errors, I dropped my database, deleted all my migration files (I left init.py). Now, when I run

python migrate.py makemigrations   /         


        
10条回答
  •  隐瞒了意图╮
    2021-01-31 18:44

    The answer to this depends if you already have a history of migrations in your app folder. In my case I didn't...I think I deleted original migration scripts.

    So following the Django docs, I did the following:

    1. Comment out new updates in models.py
    2. Follow section Adding migrations to apps...
    3. Create migrations for what is already existing:

      python manage.py makemigrations yourapp

    4. Do fake applying of these migrations (below singles that the tables already exist and not to try to recreate):

      python manage.py migrate --fake-initial

    5. Uncomment changes in model.py
    6. Follow steps in section Workflow ...

      python manage.py makemigrations yourapp

      python manage.py migrate

提交回复
热议问题