South migrate error - relation already exists

后端 未结 3 626
别跟我提以往
别跟我提以往 2021-01-11 12:04

Background: After adding djangoratings to my project, I tried running

django-admin.py schemamigration djangoratings --initial 
--settings=myapp.settings.loc         


        
3条回答
  •  不知归路
    2021-01-11 12:37

    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. Delete all djangoratings_* tables from your database.
    2. Open up the south_migrationhistory table in the database, and filter by app name. Remove all entries for djangoratings.
    3. Delete all the migrations files in the djangoratings/migrations directory.

    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.
    

    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.

提交回复
热议问题