8

what i'm trying to do is to change the default path for migrations for a specific application in a django project to put it outside the project itself but keeping it transparent, keeping use of makemigrations and migrate. Is it possible? if yes, how?

Giuseppe
  • 363
  • 5
  • 19

1 Answers1

12

Django has a MIGRATION_MODULES setting. It allows you to specify a different module for migrations per app. The module can be outside of the Django project, it just needs to be on your python path.

MIGRATION_MODULES = {'myapp': 'othermodule.db_migrations'}
Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • 1
    This is pretty handy too for when you want to move the migrations folder into a subfolder of the django app, project>app>database>migrations for example. This way, you can bundle everything that is related to the database: models and migrations. – Sander Vanden Hautte Apr 18 '18 at 12:16
  • How can I specify location for installed independent django app?. I have an installed django app which has all the models and I want to generate migration files and put them under the django project I am using the app into. How can I achieve that? – Aditya Jun 28 '20 at 23:12
  • @aditya the above answer should work. `myapp` is your installed app, and `othermodule.db_migrations` is in your Django project. – Alasdair Jun 29 '20 at 07:56