I accidentally deleted the migrations folder and now python manage.py makemigrations does not detect the changes in my models. What do I do?
shubham@shubham-PC:~/Documents/try/ecommerce$ python manage.py makemigrations
No changes detected
The repository is here
Deleting migration files means losing your history. This historical info is recorded in the django_migrations table in your database. if you delete migration files, you will get dependency errors. So Don't try to lose your history by deleting your migration files.
Go through each of your project's app migration folders and remove everything inside, except for the __init__.py file. It will remove all the migrations files inside your project. Run the python manage.py showmigrations again. That's all.
There is no possible way to recover already deleted Migration Projects. Deleted Project(s) have to be re-created manually.
Try with python manage.py makemigrations app_name
.
Edit: Django allows you to have apps without migrations within your projects. This is detected with the migrations
folder. If an app does not have it, it won't create the migrations when using the python manage.py makemigrations
command although you have it in INSTALLED_APPS
. To force an application to work with migrations you need to specify the name of the application. Btw, this is not necessary for applications you create with new versions of Django because they are created with the migrations
folder. This is only necessary when you remove the migrations folder (as you did) or when working with applications created with older versions of Django.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With