django 1.7 migrate gets error “table already exists”

后端 未结 3 1226
长情又很酷
长情又很酷 2020-12-02 08:59

I am trying to apply a migration but am getting the error:

django.db.utils.OperationalError: (1050, \"Table \'customers_customer\' already exists\")

3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 09:01

    If you have the table created in the database, you can run

    python manage.py migrate --fake 
    

    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

提交回复
热议问题