Allow a model's Meta to specify a single multi-db alias
|Reported by:||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Some, perhaps most models are clearly intended to work only with one connection or another in a multi-db project.
Currently you can specify:
objects = ModelManager().db_manager('legacy')
but I think the manager by default could look for:
connection = 'legacy'
and automatically bind to that connection
also I've run into a problem when running tests. the test runner causes each connection to create a test db which then creates all models on all connections.
if a connection does not support gis, or the model is not intended to be run on that connection ever, then the test db shouldn't create that table. thus I think that a model should be able to specify a single connection alias.
the above Meta setting would allow create_test_db to only create tables as needed for that connection.