Opened 12 years ago
Closed 12 years ago
#18878 closed Bug (duplicate)
syncdb for secondary non-default database generates error due to django_content_type
Reported by: | 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
Change History (3)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
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 by , 12 years ago
Resolution: | → duplicate |
---|---|
Status: | new → 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!
Isn't this a duplicate of #16039?