nashvegas ships with two management commands, upgradedb and comparedb.
The first, upgradedb, will manage the creation, listing, and execution of
individual migrations. The second, comparedb, is currently an experimental
command that attempts to help you discover missing migrations.

Part of the simplicity of this solution is based on the naming conventions of
the sql scripts. They should be named in a manner that enforces order. Some
examples include:

0001_short_comment_about_migration.sql
0001.sql

The model, nashvegas.Migration will get synced into your database if it
doesn’t exist when you go to execute any of the upgradedb commands. In this
model the scripts that have been executed will be recorded, effectively
versioning your database.

In addition to sql scripts, --execute will also execute python scripts that
are in the directory. This are run in filename order interleaved with the sql
scripts. For example:

0001.sql
0002.py
0003.sql

The Python script will be executed 2nd between 0000.sql and 0003.sql. The script will only be executed if the module contains a callable named migrate. It is a good idea to put all your executing code within a class or series of functions or within a single migrate() function so as to avoid code executing upon import.

For example, your script might look like this if you need to update all your
product codes on next release:

The comparedb command is available only for advanced system administrators.
It proceeds as such:

get the SQL structure dump of the current database

create a new database, the “compare” database

syncdb in the “compare” database,

get the SQL structure dump of the “compare” database

output the diff

It executes a few raw shell commands which you might need to customize to add
user credentials, encoding or specify database templates. This can be done
through the NASHVEGAS dictionnary in your setting.