Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django South migration to different databases

Does South honor database routers? I set up routers to route certain apps to one DB, and all other apps to the default DB. I even made sure that South migrationhistory table is in both DBs. But I can't get South to only apply migrations in the appropriate DB. I.e. even when I run south with --database, it applies all migrations to the database I specify, rather than just migrations from the app that should go to that DB.

Help! Thanks.

like image 632
Overclocked Avatar asked Jul 27 '12 14:07

Overclocked


People also ask

What is South migration in Django?

South is a migration tool used with Django. There will be times when you would be adding fields to a model or changing the type of field (eg: Field was an IntegerField and you want to change it to FloatField). In such cases syncdb doesn't help and South comes to your rescue.

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

"Does South honor database routers?" No, it does not.

The problem is that Django's DB router routes queries to databases based on Apps/Models, whereas south is based on Tables. South really doesn't have much idea which model a table corresponds to (esp in the history). Andrew Godwin is currently working on a contrib module to django that will replace south and fix a lot of these problems, but right now you have to do a lot of this work manually using hacky methods (--database, .using()).

I'd recomend for the sake of automation, having all tables exist in all databases and running all the migrations against all of those databases too. Just to make sure that all the constraints work consistently across all of the databases.

like image 181
Thomas Avatar answered Oct 25 '22 02:10

Thomas