Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

shared DB across django projects

Our product has a restful API and a server rendered app (the CMS). Both share the database. Both are written in django

The fields and the models needed in both are not mutually exclusive, there are some only particular to the API, some particular to the CMS, and some which are common.

My question is if I run migrations on one of the repos will they try to drop the fields that aren't present in the models of that particular repo, and needed by the other. Will running the migrations individually in both repos keep the database up to date and not pose a problem.

like image 967
madhukar93 Avatar asked May 23 '15 13:05

madhukar93


2 Answers

The only other valid option IMHO (besides merging projects) is turning off automation of Django migrations on common models (Meta.managed = False) and taking table creation & versioning into your own hands. You still can write migration scripts using django.db.migrations but makemigrations command won't do anything for these tables.

like image 58
Łukasz Haze Avatar answered Oct 25 '22 11:10

Łukasz Haze


This was solved by using a schema migration tool external to Django's own. We use yoyo migrations to migrate our schema now.

like image 30
madhukar93 Avatar answered Oct 25 '22 12:10

madhukar93