Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to change the 'migrations' folder's location outside of the Django project?

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?

like image 455
Giuseppe Avatar asked Sep 29 '17 09:09

Giuseppe


People also ask

How do I relocate in Django?

Reset the Whole Database in Django sqlite3 and then delete all the migrations folders inside all the apps. After deleting the migrations folders, we can remake the migrations and migrate them using two commands; namely, python manage.py makemigrations and python manage.py migrate .

Where are Django migration stored?

Short answer: the migrations originate from Django apps and third party apps you installed in INSTALLED_APPS . Not the ones you defined yourself. Migrations are generated per app, and are stored in some_app/migrations .

What is difference between migrate and migration in Django?

You should think of migrations as a version control system for your database schema. makemigrations is responsible for packaging up your model changes into individual migration files - analogous to commits - and migrate is responsible for applying those to your database.


1 Answers

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'}
like image 81
Alasdair Avatar answered Oct 28 '22 08:10

Alasdair