summaryrefslogtreecommitdiff
path: root/docs/model-api.txt
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-05-22 02:24:32 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-05-22 02:24:32 +0000
commit75df13278caaceedd444c43c970c7d000f19b855 (patch)
treeda694e4bff82461ba8e589e0c5dd69974d9d7528 /docs/model-api.txt
parentdd55b5e98ac7517f8a06b8f0d69c2a2d0fe2e1b2 (diff)
Fixed #981 -- Documented backend-specific SQL files
git-svn-id: http://code.djangoproject.com/svn/django/trunk@2953 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/model-api.txt')
-rw-r--r--docs/model-api.txt21
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/model-api.txt b/docs/model-api.txt
index 6c674cb1aa..6ceabf4e3d 100644
--- a/docs/model-api.txt
+++ b/docs/model-api.txt
@@ -1658,4 +1658,25 @@ The SQL files are read by the ``sqlinitialdata``, ``sqlreset``, ``sqlall`` and
``reset`` commands in ``manage.py``. Refer to the `manage.py documentation`_
for more information.
+Note that if you have multiple SQL data files, there's no guarantee of the
+order in which they're executed. The only thing you can assume is that, by the
+time your custom data files are executed, all the database tables already will
+have been created.
+
.. _`manage.py documentation`: http://www.djangoproject.com/documentation/django_admin/#sqlinitialdata-appname-appname
+
+Database-backend-specific SQL data
+----------------------------------
+
+There's also a hook for backend-specific SQL data. For example, you can have
+separate initial-data files for PostgreSQL and MySQL. For each app, Django
+looks for a file called ``<appname>/sql/<modelname>.<backend>.sql``, where
+``<appname>`` is your app directory, ``<modelname>`` is the model's name in
+lowercase and ``<backend>`` is the value of ``DATABASE_ENGINE`` in your
+settings file (e.g., ``postgresql``, ``mysql``).
+
+Backend-specific SQL data is executed before non-backend-specific SQL data. For
+example, if your app contains the files ``sql/person.sql`` and
+``sql/person.postgresql.sql`` and you're installing the app on PostgreSQL,
+Django will execute the contents of ``sql/person.postgresql.sql`` first, then
+``sql/person.sql``.