Rizwan mohammed
Rizwan mohammed

Reputation: 11

Issue with Django Migration - "Table already exists

I'm encountering a problem while trying to run migrations in my Django project. When I run python manage.py migrate, I'm getting the following error:

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

This error seems to be related to a table already existing in the database, but I haven't manually created it, and it's not in my migration files. I've tried the following steps:

Checked migration files for any duplicates or errors. Deleted the database and recreated it. Verified that there are no stray migration files in the app.

Upvotes: 0

Views: 214

Answers (2)

cybergates
cybergates

Reputation: 29

Try:

migrate --fake

Then

migrate 

Upvotes: 0

ramiboutas
ramiboutas

Reputation: 143

Remove the record asociated to that table from the django_migrations table:

$ python manage.py dbshell
(sql) >> delete * from table django_migrations where app='myapp':

Upvotes: 0

Related Questions