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

前端 未结 10 1053
挽巷
挽巷 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:28

    Just ran into this while building a little app learning django. I wanted to create a non-null column for an existing table. There were three steps:

    1. drop the table
    2. remove the record in django_migrations
    3. remove the migration for the table in question
      • if you run "python manage.py makemigrations posts" before this step you still get the "You are trying to add a non-nullable field "

    For an actual application you'd need to supply a default value as others have pointed out.

提交回复
热议问题