Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading Pyramid/SQLAlchemy web apps

I've got a standard run of the mill Pylons Pyramid application, that uses SQLAlchemy for its database persistence.

I have set up an SQLAlchemy-migrate repo and have it functioning, but I really want to have the ability to use paster to upgrade and downgrade the database, or at least some way of having the user (after installing the egg) upgrade/downgrading the database to the version required.

I've got it built-into my app now, so upon app startup it does the version upgrade, but I would rather go with something where the user explicitly has to upgrade the database so that they know exactly what is going on, and know to make backups beforehand.

How would I go about that? How do I add commands to paste?

The way users would set up the application is:

paste make-config appname production.ini
paste setup-app production.ini#appname

To set it up the first time, to do the database upgrade or upgrade in general I would want:

paste upgrade-app production.ini#appname

Or something along those lines.

like image 725
X-Istence Avatar asked Nov 13 '22 22:11

X-Istence


1 Answers

You can create your own paster command, e.g. upgrade-app, and then call it from anywhere with paster --plugin=appname upgrade-app /path/to/production.ini appname. You can refer to how pyramid implements the PShellCommand.

like image 190
sayap Avatar answered Dec 27 '22 15:12

sayap