That being said, the most difficult issue I've been having so far with web2py on Heroku (and still haven't solved yet) is how to handle migration files.
If you guys can help me do that then it's pretty much all clear down the road ;)
So, basically, there are 4 approaches to storing data on cloud systems :
- Use a remote bucket (e.g. Amazon S3)
- Store data in the database
- Postdeploy hooks
- CVS (Git/Mercurial...)
Let's go over those :
1. Bucket
If you use a library like pyfs, you can replace the filesystem used to access local files with a remote system (a bucket). That's very handy for instance if you want to manage uploads (e.g. pictures) in web2py using a remote storage service like Amazon S3.
HOWEVER, migration files being files you need to access a lot and very fast in web2py, any latency you add in the loading of those files would drastically impact your app's responsivity.
Even using a CDN service like Cloudfront, I would highly recommend not going for that option.
2. Database
That is the preferred option so far, and the only one offered in web2py's doc.
gluon/contrib/heroku.py uses the UseDatabaseStoredFiles class to do most of the heavy lifting here.
Problem is : this class was built with GAE in consideration and you can find many explicit implementations dedicated to GAE (e.g. if gae : ...)
Using the database is a solid option when using an ephemeral filesystem.
3. Postdeploy hook
This option hasn't been explored at all so far.
Based on Heroku's
doc, one can specify explicitely what shell commands to run when building an app into a slug.
If there was a python script that could run the migrations (migrate_enabled = True, fake_migrate_all = False, lazy_tables = False), you could run it at postdeploy-time then basically disable migrations consistently throughout your project without having to worry about how one changeset would affect your production DB.
4. CVS
Including .table files in my Git changesets if the solution I'm currently using.
It makes sure your local and production environment are on the same page migration-wise, and it's a good way to remind you that your changeset may trigger migrations.
I'm not 100% sure it's the best way to do things though, and there are times when it breaks : if you don't specify explicit names for your migration files then you'll end up with tons of .table files in your changesets due to the hashed prefix being changed (why is it changed all the time anyway ??).
These are the only options I know of, and none of them is fully satisfactory so far.
What do you think ? What's the best way to handle migrations on a git-based deploy system that has an ephemeral filesystem ?