且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

南迁移错误 - 关系已经存在

更新时间:2023-08-21 14:37:04

在我看来,South 与您的数据库不同步(如果 south 已开始创建表,但随后失败而无法创建,则可能会发生这种情况完成向后迁移).我建议手动恢复数据库和南方如下(先备份你的数据库以防出错):

It sounds to me as if South is out of sync with your database (this can happen if south has started creating the tables, but then fails without being able to complete the backwards migration). I would recommend manually restoring the database and south as follows (take a back up of your db first in case of a mistake):

  1. 从您的数据库中删除所有 djangoratings_* 表.
  2. 打开数据库中的 south_migrationhistory 表,并按应用名称过滤.删除 djangoatings 的所有条目.
  3. 删除 djangoratings/migrations 目录中的所有迁移文件.

完成此操作后,您应该有一个干净的数据库和南方历史.此时,重新运行:

Once you have done this, you should have a clean database, and south history. At this point, re run:

./manage.py schemamigration djangoratings --initial

这将生成一个迁移文件.那么:

Which will generate a single migration file. Then:

./manage.py migrate djangoratings.

假设您没有遇到第一次遇到的错误,这应该设置数据库,以便您准备好使用 django 评级.

Assuming that you don't get the errors that you had the first time, this should set up the database so you are ready to use django ratings.