views:

28

answers:

2

Is there a faster way to transfer my production database to a test app?

Currently I'm doing a heroku db:pull to my local machine then heroku db:push --app testapp but this is becoming time consuming. I have some seed data but it is not nearly as accurate as simply testing with my real-world data. And since they're both stored on a neighboring AWS cloud, there must be a faster way to move the data?

I thought about using a heroku bundle, but I noticed the animate command is gone?

bundles:animate <bundle>     # animate a bundle into a new app 
A: 
Tometzky
+1  A: 

Have not tested this, but it might work.

Do this to get the URL of your source database:

heroku console "ENV['DATABASE_URL']" --app mysourceapp

Then try executing db:push with that.

heroku db:push database_url_from_before --app mytargetapp

This might not work if Heroku doesn't allow access to the DB machines from outside their network, which is probably the case. You could, perhaps, try using taps (gem that heroku db commands use internally) from within your app code somewhere (maybe a rake task). This would be even faster than the above approach because everything stays completely within AWS.

Edit:

Here's an (admittedly hacky) way to do what I described above:

Grab the database URL as in the first code snippet above. Then from a rake task (you could do it on console but you risk running into the 30 second timeout limit on console commands), execute a shell command to taps (couldn't easily determine whether it's possible to use taps directly from Ruby; all docs show use of the CLI):

`taps pull database_url_from_source_app #{ENV['DATABASE_URL']}`

The backticks are important; this is how Ruby denotes a shell command, which taps is. Hopefully the taps command is accessible from the app. This avoids the problem of accessing the database machine from outside Heroku, since you're running this command from within your app.

tfe