0.0
Repository is archived
No commit activity in last 3 years
No release in over 3 years
Ruby library for interacting with Heroku Postgres.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.8
~> 0.10
~> 10.0
~> 3.2

Runtime

~> 0.45
~> 1.8
 Project Readme

heroku-postgres

This provides a Ruby client to Heroku's Postgres service. It's been partially extracted from the Heroku command line client as it's otherwise not documented.

It was primarily built to automate creating backups for usage elsewhere. It's initially limited to just being able to do this, so if there's something missing, open an issue. It's also pretty lacking in tests for similar reasons.

Installation

Add this line to your application's Gemfile:

gem 'heroku-postgres'

And then execute:

$ bundle

Or install it yourself as:

$ gem install heroku-postgres

Usage

require 'heroku/postgres'

# login (return a client object, but you don't need that directly)
Heroku::Postgres.login('username', 'password')

# find the database by app name and database name
db = Heroku::Postgres.find('app-name', 'db-name')

# have a look at the current backups
db.backups
# => [<Heroku::Postgres::Backup id=abc>]

# capture a backup, waiting for completion
# optionally, pass true to poll until complete
backup = db.capture_backup(true)

# or, pass a block to monitor the response whilst it's created
backup = db.capture_backup(true) do |backup|
  puts backup
end

# generate a public url so you can fetch the file
backup.public_url

Contributing

  1. Fork it ( https://github.com/nickcharlton/heroku-postgres/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Author

Copyright (c) 2015 Nick Charlton nick@nickcharlton.net.