Opened 5 years ago

Closed 5 years ago

Last modified 3 years ago

#12672 closed (fixed)

Add mechanism for controlling which models are synchronized onto which database in multidb

Reported by: russellm 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: UI/UX:

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 russellm 5 years ago.
First rough draft at an implementation.
t12672-r12278.2.diff (14.4 KB) - added by russellm 5 years ago.
RC1 of a patch for configuring multiple database usage

Download all attachments as: .zip

Change History (5)

Changed 5 years ago by russellm

First rough draft at an implementation.

comment:1 Changed 5 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement set
  • Triage Stage changed from Unreviewed to 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.

Changed 5 years ago by russellm

RC1 of a patch for configuring multiple database usage

comment:2 Changed 5 years ago by russellm

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

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

comment:3 Changed 3 years ago by jacob

  • milestone 1.2 deleted

Milestone 1.2 deleted

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