DEV Community

sium_hossain
sium_hossain

Posted on

6 2

django.db.utils.ProgrammingError: column <name> of relation "app_name__table" already exists

Sometime we messed up with django migration and migrate process. Deleting migration file and run python manage.py makemigrations and python manage.py migrate solve the issue by undo previous migration or we can say that it takes us to previous migration state. But I faced one kind of situation where already a column created by a migrations and I saved some data in this column which was already created. And if i want to delete a migration file and want to go back previous situation django make sure that it doesn't happened because column is already created and I want to add this column again. And in this situation django will throw a error something like that 👇
error message

And I can't delete all my data and make migrations from zero. Because I'm in now production mode and have some data in my database. So I run this command and it's help me to overcome from this situation. And the magical command is 🧞-



python manage.py migrate --fake <put your app name>


Enter fullscreen mode Exit fullscreen mode

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more