Update: Since this was written, Heroku have added the ability to push and pull specific tables, through version 0.3 of their Taps gem. More info in their post here: Supporting Large Data
I’m still enjoying using Heroku. For deployment of Rails apps it seems like it’s almost too easy, it’ll be hard to accept anything that doesn’t quite work as smoothly.
Having praised them to death everywhere, the swearing kicked off when I tried to upload some table data for a subset of the database – the command heroku db:push will overwrite the entire database.
There are references to using the yaml_db plugin as a way to extract and reload the data from your database,
This forum post in the Heroku Google Group pretty much covers it – but here’s my written up version, for the next time I need it. This is all using bash on OS X – there will be differences if you’re on Windows.
1. Install yaml_db as a plugin (a gem would require some hacking to make the rake tasks available to your app):
2. Dump the database out as a YAML file
3. Edit the yaml file in db/data.yml using a text editor, leaving only the tables you want to upload. Add/commit this to your local Git repo.
4. You could skip this bit if you were feeling brave, but I’d recommend you do a test with the data locally before attempting it on live. Back up your local database first, and delete the table data for the tables you want to upload (not the tables themselves), and run
5. Check that your local tables contain the data you expect.
6. Push your changes to live – including your db/data.yml file.
7. Run your migration for setting up the new tables (if any):
8. Now load in the data…
At this point, your data should now have appeared in your live database. If you know of a better way than this, let me know in the comments.
14:06
Adrian Short wrote...
You can now use:
$ heroku db:push
and
$ heroku db:pull
to get your data to and from the server.
More here:
http://blog.heroku.com/archives/2009/3/18/push_and_pull_databases_to_and_from_heroku/
18:39
Steve wrote...
Sorry if I didn’t make it clear – this was more about push/pulling specific tables. This is now supported in the latest version of Taps, so hooray:
http://blog.heroku.com/archives/2010/4/21/supporting_big_data_part_1