Opened 7 years ago

Closed 7 years ago

#18878 closed Bug (duplicate)

syncdb for secondary non-default database generates error due to django_content_type

Reported by: robertpayne@… Owned by: nobody
Component: Core (Management commands) Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no


This is against Django 1.4.1

If you configure multiple databases in settings like such:

	'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',
		'HOST': 'localhost',
		'PORT': '3306',
	'test': {
		'ENGINE': 'django.db.backends.mysql',
		'NAME': 'XXX_test',
		'USER': 'XXX',
		'HOST': 'localhost',
		'PORT': '3306',

Then you run 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) runs
2) hits line 106 and commits a transaction transaction.commit_unless_managed(using=db)
3) hits line 110 and fires post_sync_signal emit_post_sync_signal(created_models, verbosity, interactive, db)
4) 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 to use the kwargdb?

Change History (3)

comment:1 Changed 7 years ago by Aymeric Augustin

Isn't this a duplicate of #16039?

comment:2 Changed 7 years ago by anonymous

Yes it is, please close as a duplicate sorry I did search the ticket tracker but couldn't find one related given my search query.

comment:3 Changed 7 years ago by Aymeric Augustin

Resolution: duplicate
Status: newclosed

Don't worry -- it took me a bit of time to locate the duplicate, and I only found it because I remembered I had seen this problem before!

Note: See TracTickets for help on using tickets.
Back to Top