django 1.7 migrate获取错误“表已存在” [英] django 1.7 migrate gets error "table already exists"
问题描述
django.db.utils.OperationalError:(1050,表'customers_customer'
已经存在)
我通过发出以下命令得到这个:
python manage.py migrate
我的客户表已经存在,所以我该怎么做让移民知道这一点,而不是出错,并将我的修改运行到我的模型?
我跑了在我的本地环境中与本地数据库没有任何问题。当我指向我的数据库进行生产并运行 migrate
以上时,我收到这个错误。
如果您在数据库中创建了表,则可以运行
python manage.py migrate - -fake< appname>
将迁移标记为运行而不实际运行
或者如果您想避免迁移中的某些操作,可以编辑app / migrations目录下的迁移文件,并对迁移执行中不想执行的操作进行注释。 / p>
文档: https:/ /docs.djangoproject.com/en/1.8/topics/migrations/#upgrading-from-south
或 python manage.py帮助迁移
I am trying to apply a migration but am getting the error:
django.db.utils.OperationalError: (1050, "Table 'customers_customer' already exists")
I get this by issuing the following command:
python manage.py migrate
My customer table already exists, so what do I do to let the migration know this, not error out, and run my modification to my model?
I ran this on my local environment with local database with no problem. It is when I pointed my database to production and ran migrate
above that I get this error.
If you have the table created in the database, you can run
python manage.py migrate --fake <appname>
Mark migrations as run without actually running them
Or if you want to avoid some actions in your migration, you can edit the migration file under the app/migrations directory and comment the operations you don't want to do in the migrate execution.
Docs: https://docs.djangoproject.com/en/1.8/topics/migrations/#upgrading-from-south
or python manage.py help migrate
这篇关于django 1.7 migrate获取错误“表已存在”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!