Option to use this on Heroku
besi opened this issue · 7 comments
To push a dump to heroku, or to make a dump from heroku?
Both cases might make sense:
- Push to Heroku: Seed an Application with initial Data (My initial thought, when I posted this issue)
- Load from Heroku: Load a DB Dump for backup or mirroring the production environment
@besi If you spin up a local copy of your Rails app, you can configure its database.yml to point to your Heroku database based on the URL returned by heroku config:get DATABASE_URL
. This will work for pulling or pushing. Does this cover your use case?
Closing for lack of feedback.
@dnrce this would certainly cover my usecase for a one-time thing, however, if I regularly want to pull and push data to heroku I guess this would be too cumbersome. I am more thinking of an automated way to do this.
I am in a similar position now with another project so I will look for options to do this.
- Import Dump on Heroku 1 (Hack):Here I could just check in the
data.yml
and then load the file using rake - Import Dump on Heroku: Another way to import a dump would be to have a UI with a textarea, where I can paste the contents of the
data.yml
which would then be loaded. For this option I would have to figure out, how the data can be imported easily. - Export Dump from Heroku: Here it would be nice to be able to export the yml to the STDOUT (#40) rather than a file. Like this I could get a dump from heroku easily. Or similarly I could just display the
data.yml
in the UI somewhere or download it through some special route like http://myapp.herokuapp.com/dumps/data.yml
Another way to rapidly switch the database configuration is to make use of the DATABASE_URL
environment variable locally -- something like DATABASE_URL=
heroku config:get DATABASE_URL bundle exec rake db:data:load
might do the trick.
@dnrce This did not work, with the help of your feedback I got it working:
-
Run
heroku config:get DATABASE_URL
to get the pg url -
Configure the
database.yml
production according to the `DATABASE_URL:# heroku config:get DATABASE_URL # postgres://yyyy:xxxx@something.compute-1.amazonaws.com:5432/zzzz production: adapter: postgresql username: yyyy password: xxxx host: something.compute-1.amazonaws.com port: 5432 database: zzzzz
-
Create a dump and load it into the development db
RAILS_ENV=production bin/rake db:data:dump bin/rake db:data:load