There is no clever trickiness, magic, or other intelligence to automatically generate your sql. For that you should be using South. With cuckoo, you write sql patches, and the application keeps track of which have already been applied. You might use it because you like to hand-roll your sql, or because you have messed with your django and intelligent migrations fail.
Cuckoo works as follows:
- You write some sql patches
- Put them in a directory
- Run
./manage.py cuckoo
to execute any patches that haven't yet been run
The easiest way is to use the pip
installer:
pip install git+ssh://git@github.com/dragonfly-science/cuckoo.git
- Add
cuckoo
toINSTALLED_APPS
in your settings file - Make a directory, by default
sql-patches
, to hold your patches - Optionally, add a string
CUCKOO_DIRECTORY
to your settings file that holds the full path to the directory where you store your patches, e.g.,CUCKOO_DIRECTORY = '/home/edward/django/www/patches'
- Run ./manage.py syncdb, or pipe the output from
./manage.py sql cuckoo
at your database
When you install cuckoo, it creates a table cuckoo_patch
in your database. This table
holds a record of the patches that have been run. A Patch object has the fields
- patch: The filename of the patch (must be unique)
- sql: The content of the patch file (not really necessary)
- output: The output from running the patch
- last_updated: When the patch was actually run.
Cuckoo needs to know how to find the database. There are two ways of doing this.
- The standard django way, see https://docs.djangoproject.com/en/dev/ref/settings/#databases
- By setting a
CUCKOO_DATABASE_STRING
string, with%s
indicating where the patch filename should be substituted. This is useful if your sql patches contain commands that are not parsed by the python database connection layer. For a postgres database you might havedatabase_string = 'psql %(NAME)s -U %(USER)s -h %(HOST)s -f '%DATABASES['default']
in your settings file, withCUCKOO_DATABASE_STRING = database_string + '%s'
.
The shining cuckoo migrates from the Solomon Islands, Papua Guinea region to New Zealand in the spring. It breeds in New Zealand in the summer. It has a distinctive call, and is often heard, but rarely seen. Cuckoos lay their eggs in the nest of other birds (the shining cuckoo parasitises the grey warbler). The cuckoo migrations systems lets you put whatever you want into the django nest.