Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to manage django missing migration files of 3rd party apps?

I have a problem with migrations on heroku. I have just upgraded version of django from 1.8.1 to 1.8.2 in my project on heroku, because of some missing migrations:

https://github.com/django/django/blob/1.8/django/contrib/auth/migrations/0005_alter_user_last_login_null.py#L14-L18

After this upgrade, on my local project I was forced to do standard procedure: python manage.py makemigrations python manage.py migrate

Of course this new, generated migrations are outside of my git repository. If I will run heroku run this will generate new migrations in new dyno, so without any impact on my current slug.

What is the best solution for this situation? How to generate migrations or add missing migrations of django or 3rd part libs when e.g. you are doing upgrade of the libs? What is the best working strategy?

like image 583
pmoniq Avatar asked May 21 '15 19:05

pmoniq


People also ask

How does Django keep track of migrations?

Django keeps track of applied migrations in the Django migrations table. Django migrations consist of plain Python files containing a Migration class. Django knows which changes to perform from the operations list in the Migration classes. Django compares your models to a project state it builds from the migrations.

Can I delete migration files Django?

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.


1 Answers

Answer is quiet trivial, could be useful for others. To use MIGRATION_MODULES is the correct answer.

https://docs.djangoproject.com/en/1.8/ref/settings/#std:setting-MIGRATION_MODULES

like image 56
pmoniq Avatar answered Sep 21 '22 23:09

pmoniq