Very mainstream problem :-
-
I’ve a production database in postgres that’s connected with my django projects which has multiple apps.
-
I’ve 2 aspects to look at :-
2.1. I need to delete the migrations folder and get rid of actually 100’s of migrations files in the apps.
2.2. I need to delete the migrations that django creates in the database as well in the django_migrations table.
-
I want to make sure that Production data is not lost in any case!
Finally I should have only 1 migration file or 2 that 0001/2_initial.py that’s created by Django AND in the django_migrations table as well I need to make sure that all older migrations are deleted and it too has the newer initial ones created by django.
I tried to delete all migrations folder and delete the django_migration table and then i ran
python manage.py makemigrations
python manage.py migrate
but it gave me error saying that 'X' table already exists!
luckily I had the dump and restored the data.
Ikshan Bhardwaj is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1