Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude an app from Django migrations

Is there a way to exclude models of an app from Django migrations? I know changing the model meta options with managed = False is an option but that's a lot of models to edit every time. Is there a way to specify an app whose models I don't want to migrate?

like image 417
cookiedough Avatar asked Jul 25 '17 15:07

cookiedough


People also ask

What is the difference between Makemigrations and migrate in Django?

migrate , which is responsible for applying and unapplying migrations. makemigrations , which is responsible for creating new migrations based on the changes you have made to your models.

What does fake migration do in Django?

To deal with such cases, Django provides a way called fake migration, which applies the migration but does not affect the database schema. In simpler words, for each migration which is faked, an entry is created in django_migrations table but no changes are done in the database schema.


2 Answers

remove the app from installed apps in your settings.

like image 58
Ian Kirkpatrick Avatar answered Sep 17 '22 15:09

Ian Kirkpatrick


Removing the __init__.py file from within the apps migrations directory should work.

like image 29
Ben Petty Avatar answered Sep 16 '22 15:09

Ben Petty