diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-11-22 20:09:40 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-11-22 20:53:59 +0100 |
| commit | a026e480da89cb99c9dc6c954fb5a37ded0f9315 (patch) | |
| tree | 5203483ad859b6849a2b7785281c62e007cd9317 /docs | |
| parent | ea6b95dbec77371d517392ffb465017b8eb7001c (diff) | |
Fixed #16039 -- Made post_syncdb handlers multi-db aware.
Also reverted 8fb7a9002669fb7ba7bec7df90b465b92e1ed3c2. Refs #17055.
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/releases/1.5.txt | 14 | ||||
| -rw-r--r-- | docs/topics/db/multi-db.txt | 46 |
2 files changed, 60 insertions, 0 deletions
diff --git a/docs/releases/1.5.txt b/docs/releases/1.5.txt index b73bb041e9..e26b927ae7 100644 --- a/docs/releases/1.5.txt +++ b/docs/releases/1.5.txt @@ -551,6 +551,20 @@ with the :meth:`~django.forms.Form.is_valid()` method and not with the presence or absence of the :attr:`~django.forms.Form.cleaned_data` attribute on the form. +Behavior of :djadmin:`syncdb` with multiple databases +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +:djadmin:`syncdb` now queries the database routers to determine if content +types (when :mod:`~django.contrib.contenttypes` is enabled) and permissions +(when :mod:`~django.contrib.auth` is enabled) should be created in the target +database. Previously, it created them in the default database, even when +another database was specified with the :djadminopt:`--database` option. + +If you use :djadmin:`syncdb` on multiple databases, you should ensure that +your routers allow synchronizing content types and permissions to only one of +them. See the docs on the :ref:`behavior of contrib apps with multiple +databases <contrib_app_multiple_databases>` for more information. + Miscellaneous ~~~~~~~~~~~~~ diff --git a/docs/topics/db/multi-db.txt b/docs/topics/db/multi-db.txt index d2ff8645a9..8a02305376 100644 --- a/docs/topics/db/multi-db.txt +++ b/docs/topics/db/multi-db.txt @@ -630,3 +630,49 @@ However, if you're using SQLite or MySQL with MyISAM tables, there is no enforced referential integrity; as a result, you may be able to 'fake' cross database foreign keys. However, this configuration is not officially supported by Django. + +.. _contrib_app_multiple_databases: + +Behavior of contrib apps +------------------------ + +Several contrib apps include models, and some apps depend on others. Since +cross-database relationships are impossible, this creates some restrictions on +how you can split these models across databases: + +- each one of ``contenttypes.ContentType``, ``sessions.Session`` and + ``sites.Site`` can be stored in any database, given a suitable router. +- ``auth`` models — ``User``, ``Group`` and ``Permission`` — are linked + together and linked to ``ContentType``, so they must be stored in the same + database as ``ContentType``. +- ``admin`` and ``comments`` depend on ``auth``, so their models must be in + the same database as ``auth``. +- ``flatpages`` and ``redirects`` depend on ``sites``, so their models must be + in the same database as ``sites``. + +In addition, some objects are automatically created just after +:djadmin:`syncdb` creates a table to hold them in a database: + +- a default ``Site``, +- a ``ContentType`` for each model (including those not stored in that + database), +- three ``Permission`` for each model (including those not stored in that + database). + +.. versionchanged:: 1.5 + Previously, ``ContentType`` and ``Permission`` instances were created only + in the default database. + +For common setups with multiple databases, it isn't useful to have these +objects in more than one database. Common setups include master / slave and +connecting to external databases. Therefore, it's recommended: + +- either to run :djadmin:`syncdb` only for the default database; +- or to write :ref:`database router<topics-db-multi-db-routing>` that allows + synchronizing these three models only to one database. + +.. warning:: + + If you're synchronizing content types to more that one database, be aware + that their primary keys may not match across databases. This may result in + data corruption or data loss. |
