﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
18878	syncdb for secondary non-default database generates error due to django_content_type	robertpayne@…	nobody	"This is against Django 1.4.1

If you configure multiple databases in settings like such:


{{{
DATABASES = {
	'production': {
		'ENGINE': 'django.db.backends.mysql',
		'NAME': 'XXX_pro',
		'USER': 'XXX',
		'PASSWORD': 'satmed88',
		'HOST': 'localhost',
		'PORT': '3306',
	},
	'default': {
		'ENGINE': 'django.db.backends.mysql',
		'NAME': 'XXX_dev',
		'USER': 'XXX',
		'PASSWORD': 'XXX',
		'HOST': 'localhost',
		'PORT': '3306',
	},
	'test': {
		'ENGINE': 'django.db.backends.mysql',
		'NAME': 'XXX_test',
		'USER': 'XXX',
		'PASSWORD': 'XXX',
		'HOST': 'localhost',
		'PORT': '3306',
	},
}
}}}

Then you run {{{ manage.py syncdb --database=production }}} it will fail with an error django.db.utils.DatabaseError: (1146, ""Table 'XXX_dev.django_content_type' doesn't exist"")

Here is what I believe is happening:

1) django.core.management.syncdb.py runs
2) django.core.management.syncdb.py hits line 106 and commits a transaction {{{ transaction.commit_unless_managed(using=db) }}}
3) django.core.management.syncdb.py hits line 110 and fires post_sync_signal {{{ emit_post_sync_signal(created_models, verbosity, interactive, db) }}}
4) django.contrib.contentypes.management.py handles this post_sync_signal and while it does receive the selected db in the kwargs it never uses the db but just runs against the default routed database.


Simple fix would be to patch django.contrib.contentypes.management.py to use the kwarg['db']"	Bug	closed	Core (Management commands)	1.4	Normal	duplicate			Unreviewed	0	0	0	0	1	0
