Code

#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

Description

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 kwargdb?

Attachments (0)

Change History (3)

comment:1 Changed 20 months ago by aaugustin

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Isn't this a duplicate of #16039?

comment:2 Changed 20 months 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 20 months ago by aaugustin

  • Resolution set to duplicate
  • Status changed from new to closed

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!

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.