Ptah migration based on alembic package. Ptah adds per package migration. Migration is not required alembic environment.
You can use alembic operations for ddl manipulation. Here are the steps for ptah migrations generation.
For example:
1 2 $ cd ptah_minicms $ mkdir migrationsSo directory listing should look like this:
1 2 3 4 5 6 $ ls -l drwxrwxr-x 2 fafhrd fafhrd 4096 2012-01-11 15:58 migrations drwxrwxr-x 2 fafhrd fafhrd 4096 2011-12-16 11:33 static drwxrwxr-x 2 fafhrd fafhrd 4096 2011-12-29 14:50 templates -rw-rw-r-- 1 fafhrd fafhrd 1457 2011-12-29 14:50 actions.py ...
1 2 3 4 5 import ptah ptah.register_migration( 'ptah_minicms', 'ptah_minicms:migrations', 'Ptah minicms example migration')First parameter is package name, second parameter is asset style path and third parameter migration title.
1 2 $ /bin/ptah-migrate settings.ini revision ptah_minicms -r 001 -m "Add column" Generating /path-to-virtualenv/ptah_minicms/migrations/001.py...doneGenerated script contains empty update() and downgrade() function. Add code that does migration from previous revision to this function.
1 2 $ bin/ptah-migrate settings.ini upgrade ptah_minicms 2012-01-11 16:14:42,657 INFO [ptah.alembic] ptah_minicms: running upgrade None -> 001
Check Data migration chapter for ptah-migrate script detailed description.
Use ptah_migrate() pyramid directive for migration data schema during startup.
import ptah
from pyramid.config import Configurator
def main(global_settings, **settings):
config = Configurator(settings=settings)
config.include('ptah')
...
config.ptah_migrate()
...
return config.make_wsgi_app()
Migration steps are executed after configration commited.