Opened 15 years ago

Closed 15 years ago

Last modified 13 years ago

#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)

t12672-r12278.1.diff (9.1 KB ) - added by Russell Keith-Magee 15 years ago.
First rough draft at an implementation.
t12672-r12278.2.diff (14.4 KB ) - added by Russell Keith-Magee 15 years ago.
RC1 of a patch for configuring multiple database usage

Download all attachments as: .zip

Change History (5)

by Russell Keith-Magee, 15 years ago

Attachment: t12672-r12278.1.diff added

First rough draft at an implementation.

comment:1 by Russell Keith-Magee, 15 years ago

Patch needs improvement: set
Triage Stage: UnreviewedDesign 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 Russell Keith-Magee, 15 years ago

Attachment: t12672-r12278.2.diff added

RC1 of a patch for configuring multiple database usage

comment:2 by Russell Keith-Magee, 15 years ago

Resolution: fixed
Status: newclosed

(In [12290]) Fixed #12672 -- Added the ability to configure which applications are available on which database.

comment:3 by Jacob, 13 years ago

milestone: 1.2

Milestone 1.2 deleted

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