Answer the question
In order to leave comments, you need to log in
How to make migrations work with admin/auth/contenttypes on multiple db?
Available:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'foo',
'bar'
}
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR + '/var/db.sqlite'
},
'foo': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'HOST': 'foohost',
'NAME': 'foo'
},
'bar': {
'ENGINE': 'django.db.backends.postgresql',
'HOST': '',
'NAME': 'bar'
}
}
DATABASE_ROUTERS = ['regions.dbrouter.DbRouter'] # возвращает тупо model._meta.app_label
./manage.py migrate auth
./manage.py migrate admin
./manage.py migrate sessions
# к этому моменту всяческие contenttype и permissions для всех обнаруженных приложений уже созданы
./manage.py migrate foo --database=foo
# тут срабатывает post_migrate_signal и auth/contenttypes лезет в базу foo за своими таблицами...
Answer the question
In order to leave comments, you need to log in
Workaround: disable contrib (including admin urls), do migrations, and then enable contrib back.
What threatens - it is not clear.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question