#12672 closed (fixed)
Add mechanism for controlling which models are synchronized onto which database in multidb
Reported by: | Russell Keith-Magee | Owned by: | nobody |
---|---|---|---|
Component: | Database layer (models, ORM) | Version: | 1.1 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Design decision needed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | no |
Description
At present synchronizing multiple databases where you *dont* want certain models on certain databases is a little fiddly. If you want to exclude an entire app, you can use --exclude on syncdb, but if you just want to disable a a single model, you can't - you need to manually roll out your synchronization. There is also a problem during testing, since that can't be manually implemented.
The usual suggestion here is an entry in settings.py, which would be exceedingly verbose and for the simple case, and worse for the complex case.
However, a programmatic approach leveraging the new Database Router should work. We could add an 'allow_syncdb(using, model)' interface to syncdb; this gets interrogated by syncdb (and other places that need it) to determine if a model should be visible on the given alias. Default behaviour is "yes"; the method can return True/False/None in the same way that allow_relation does right now.
This would allow us to remove --exclude options from loaddata and syncdb, allows for test syncdb calls to be more specific, and would allow syncdb under normal operation to be completely automated.
Attachments (2)
Change History (5)
by , 15 years ago
Attachment: | t12672-r12278.1.diff added |
---|
comment:1 by , 15 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
This first patch isn't complete - it isn't heavily tested, and it still needs documentation. I'm just throwing it out there for feedback.
by , 15 years ago
Attachment: | t12672-r12278.2.diff added |
---|
RC1 of a patch for configuring multiple database usage
comment:2 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
First rough draft at an implementation.