Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django 1.8: Migrations not detected after deleting migrations folder

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

like image 896
FlyingAura Avatar asked Jun 26 '15 08:06

FlyingAura


People also ask

What happens if I delete Django migrations?

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.

Can I delete migrations folder in Django?

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.

How do I restore deleted migrations?

There is no possible way to recover already deleted Migration Projects. Deleted Project(s) have to be re-created manually.


1 Answers

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.

like image 134
argaen Avatar answered Sep 22 '22 01:09

argaen