It's hard for me to create data migration. I use two databases for my applications. I set up the databases in settings.py and also created a router, as in Django docs .
# settings.py DB_HOST = 'localhost' DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'helios', 'HOST': DB_HOST, 'OPTIONS': { 'read_default_file': join(dirname(__file__), 'default.cnf'), }, }, 'other': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'gala_pol', 'HOST': DB_HOST, 'OPTIONS': { 'read_default_file': join(dirname(__file__), 'other.cnf'), }, }, DATABASE_APPS_MAPPING = { 'contenttypes': 'default', 'auth': 'default', 'admin': 'default', 'sessions': 'default', 'messages': 'default', 'staticfiles': 'default', 'woodsmen': 'default', 'helios': 'default', 'hush': 'default', 'hunt': 'other', 'meat': 'other', 'beast': 'other', }
Here is the model and migration of one of these applications:
# hunt.models.py class Dish(models.Model): """ Investigation case """ display_name = models.CharField(max_length=64, unique=True) department = models.ForeignKey(Kitchen, null=True) case_type = models.PositiveSmallIntegerField(choices=CASE_TYPE_CHOICES, default=DEF_CASE_TYPE) created_at = models.DateTimeField(blank=True, null=True) comment = models.CharField(max_length=256, blank=True, null=True) class Meta: verbose_name = 'case' app_label = 'hunt' def __unicode__(self): return (u'%s (%s)' % (self.display_name, self.created_at)).strip()
The problem is this: When I run the "migrate" command, only applications connected to the database by default are migrated. Migrations in other applications never start. If I start a migration for such an application with the --database option - it works fine.
How can I specify a database for each migration? Shouldn't a router handle just that? Or am I missing something else?