Django 1.7 migrations won't recreate a dropped table, why?

前端 未结 10 1055
挽巷
挽巷 2020-12-23 14:16

Using Django 1.7 migrations.

I accidentally dropped a table in my database. I assumed that by running migration again this would recreate the table but no, Django st

10条回答
  •  误落风尘
    2020-12-23 14:51

    Another solution I've found and works perfectly:

    In django 1.7:

    1. Delete your migrations folder

    2. In the database: DELETE FROM django_migrations WHERE app = 'app_name'.

      You could alternatively just truncate this table.

    3. python manage.py makemigrations

    4. python manage.py migrate --fake

    In django 1.9.5:

    1. Delete your migrations folder

    2. In the database: DELETE FROM django_migrations WHERE app = 'app_name'.

      You could alternatively just truncate this table.

    3. python manage.py makemigrations app_name

    4. python manage.py migrate

    This works 100% for me!

提交回复
热议问题