Translate Toolkit & Pootle

Tools to help you make your software local

User Tools

Database Schema Upgrade

Users following Pootle development have to deal with model changes that require changes to database schema. Until recently we asked users to recreate their databases from scratch, but that's not always possible.

Schema updates are not easy in Django but the Django Command Extensions provides a sqldiff command for that works for many cases. It seems to work fine with MySQL for the types of changes we've been doing between the various betas and RCs of Pootle 2.0.0, but fails with SQLite though.


Install django-command-extensions using easy_install

 easy_install django-extensions

Add the following line to

 INSTALLED_APPS += ("django_extensions",)

Now command extensions are ready to be used, if you use the sqldiff manage command it will show SQL instructions for updating the database

 ./ sqldiff -a

You need to pass these SQL instructions to your RDBMS, easiest way is to use the dbshell manage command

 ./ sqldiff -a | ./ dbshell

If the syntax produced by sqldiff is incorrect (happens with sqlite3) you can get a textual description of the changes needed and do them manually instead

 ./ sqldiff -a -t

If you are running from install the file won't be available, use command with the option --settings=pootle.settings instead.

So for example

 ./ sqldiff -a

Becomes sqldiff -a --settings=pootle.settings