Django

Code

Changeset 2953

Show
Ignore:
Timestamp:
05/21/06 21:24:32 (2 years ago)
Author:
adrian
Message:

Fixed #981 -- Documented backend-specific SQL files

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/model-api.txt

    r2945 r2953  
    16591659for more information. 
    16601660 
     1661Note that if you have multiple SQL data files, there's no guarantee of the 
     1662order in which they're executed. The only thing you can assume is that, by the 
     1663time your custom data files are executed, all the database tables already will 
     1664have been created. 
     1665 
    16611666.. _`manage.py documentation`: http://www.djangoproject.com/documentation/django_admin/#sqlinitialdata-appname-appname 
     1667 
     1668Database-backend-specific SQL data 
     1669---------------------------------- 
     1670 
     1671There's also a hook for backend-specific SQL data. For example, you can have 
     1672separate initial-data files for PostgreSQL and MySQL. For each app, Django 
     1673looks for a file called ``<appname>/sql/<modelname>.<backend>.sql``, where 
     1674``<appname>`` is your app directory, ``<modelname>`` is the model's name in 
     1675lowercase and ``<backend>`` is the value of ``DATABASE_ENGINE`` in your 
     1676settings file (e.g., ``postgresql``, ``mysql``). 
     1677 
     1678Backend-specific SQL data is executed before non-backend-specific SQL data. For 
     1679example, if your app contains the files ``sql/person.sql`` and 
     1680``sql/person.postgresql.sql`` and you're installing the app on PostgreSQL, 
     1681Django will execute the contents of ``sql/person.postgresql.sql`` first, then 
     1682``sql/person.sql``.