I've been using django migration to handle database. recently, I split session into two, one is for reading and the other one is for writing. After done this, I made new migration file that adding new table and run it. It was successful,
Operations to perform:
Apply all migrations: food
Running migrations:
Applying food.0107_auto_20171116_0849... OK
However, when I checked mysql database using shell, there was no new table. I deleted django migrations history and attempted few times more but the result was same. It says migration applied but there was no new table. This is my migration file
# -*- coding: utf-8 -*-
# Generated by Django 1.11.2 on 2017-11-16 08:49
from __future__ import unicode_literals
from django.db import migrations, models
import uuid
class Migration(migrations.Migration):
dependencies = [
('bubi', '0106_auto_20171110_1452'),
]
operations = [
migrations.CreateModel(
name='FoodHistory',
fields=[
('id', models.UUIDField(default=uuid.uuid4, primary_key=True, serialize=False)),
('date', models.DateField(verbose_name='updated date')),
],
options={
'verbose_name': 'food updated date',
'verbose_name_plural': 'food updated date',
},
),
]
I wonder if splited session may affects to do migrations. thanks!
EDIT
I added my local_settings.py
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'food',
'HOST': '127.0.0.1',
'USER': 'apple',
'PASSWORD': 'apple'
},
'read': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'food',
'HOST': '127.0.0.1',
'USER': 'apple',
'PASSWORD': 'apple'
},
'write': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'food',
'HOST': '127.0.0.1',
'USER': 'apple',
'PASSWORD': 'apple'
}
}
If you use multiple DBs in Django, When migrating, you need to check the Database Router that you coded.
Check for "allow_migrate" method in your database router class.
This is official Django documentation about this issue.
https://docs.djangoproject.com/ko/1.11/topics/db/multi-db/#allow_migrate
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With