Rename allow_syncdb to allow_migrate

This commit is contained in:
Andrew Godwin 2013-07-30 12:08:59 +01:00
parent 68e0a169c4
commit 12e9804d16
17 changed files with 61 additions and 47 deletions

View file

@ -215,8 +215,8 @@ operations to ``cache_slave``, and all write operations to
return 'cache_master'
return None
def allow_syncdb(self, db, model):
"Only synchronize the cache model on master"
def allow_migrate(self, db, model):
"Only install the cache model on master"
if model._meta.app_label in ('django_cache',):
return db == 'cache_master'
return None

View file

@ -155,14 +155,17 @@ A database Router is a class that provides up to four methods:
used by foreign key and many to many operations to determine if a
relation should be allowed between two objects.
.. method:: allow_syncdb(db, model)
.. method:: allow_migrate(db, model)
Determine if the ``model`` should be synchronized onto the
Determine if the ``model`` should have tables/indexes created in the
database with alias ``db``. Return True if the model should be
synchronized, False if it should not be synchronized, or None if
migrated, False if it should not be migrated, or None if
the router has no opinion. This method can be used to determine
the availability of a model on a given database.
Note that if this returns ``True`` for an app with migrations but
``False`` for an app those migrations depend on, Django will error.
A router doesn't have to provide *all* these methods -- it may omit one
or more of them. If one of the methods is omitted, Django will skip
that router when performing the relevant check.
@ -288,7 +291,7 @@ send queries for the ``auth`` app to ``auth_db``::
return True
return None
def allow_syncdb(self, db, model):
def allow_migrate(self, db, model):
"""
Make sure the auth app only appears in the 'auth_db'
database.
@ -328,7 +331,7 @@ from::
return True
return None
def allow_syncdb(self, db, model):
def allow_migrate(self, db, model):
"""
All non-auth models end up in this pool.
"""
@ -347,7 +350,7 @@ be queried in the order the are listed in the
result, decisions concerning the models in ``auth`` are processed
before any other decision is made. If the :setting:`DATABASE_ROUTERS`
setting listed the two routers in the other order,
``MasterSlaveRouter.allow_syncdb()`` would be processed first. The
``MasterSlaveRouter.allow_migrate()`` would be processed first. The
catch-all nature of the MasterSlaveRouter implementation would mean
that all models would be available on all databases.