2

I need to tell Django not to apply already existing migrations for a model. Is there a way I can achieve it?

Why: I have some customizations on top of django.contrib.auth. With those, Group model is left unused. However, migrations for it are included into the auth app. Unlike User, Group is not swappable.

Art
  • 2,235
  • 18
  • 34

2 Answers2

4

You can set MIGRATION_MODULES and django will use migrations from setted directory for app

MIGRATION_MODULES = {'django.contrib.auth': 'local_package'}
Sardorbek Imomaliev
  • 14,861
  • 2
  • 51
  • 63
0

You can simply edit the migrations files. So, simply comment out the parts you don't want to be applied.

You can also set your Model to be managed=False , but I'm not sure if that is what you need.

Alex
  • 5,759
  • 1
  • 32
  • 47
  • 1
    Editing migrations could be an option, would they belong to me. But they are in ```django.contrib.auth```, and I don't feel like having my own repository with a django branch because of it :( ```managed=False``` in ```Meta``` prevents migrations from being created. – Art Nov 07 '16 at 08:28
  • i dont see the problem. Please describe more clearly what you have and what you want. – Alex Nov 07 '16 at 08:33
  • The problem is this: https://github.com/django/django/tree/master/django/contrib/auth/migrations Those migrations are shipped with Django. When I need to deploy my projects on production, I install Django from pip. – Art Nov 07 '16 at 08:38