2012-06-08 38 views

cevap

7

Evet, doğrudan bir uygulama DB'sinden diğerine bir çatal oluşturabilirsiniz. yapmak için bu ardından birincil uygulamasından DATABASE_URL için değeri elde aşağıdaki komutu kullanabilirsiniz: Craig'in cevabı ekleme

heroku addons:add heroku-postgresql:ronin --fork postgres://username:[email protected]/database --app yourstagingapp 
+0

, teşekkür – Alex

+0

postgres almak için –

3

, burada bütün işi yapar a script by freeformz bu. // url, koşmak $ Heroku yapılandırma ve DATABASE_URL hattını kapmak (veya HEROKU_POSTGRESQL_color_URL):

Mükemmel
app=${1} 
db_type=${2:-ronin} 

old_db=`heroku config -a ${app}-staging | grep ^HEROKU_POSTGRESQL | cut -d : -f 1 | sed s/_URL//` 
heroku addons:add heroku-postgresql:${db_type} --fork `heroku config -a ${app} | grep ^DATABASE_URL | cut -d : -f 2-5` -a ${app}-staging 
new_db=`heroku config -a ${app}-staging | grep ^HEROKU_POSTGRESQL | grep -v ${old_db} | cut -d : -f 1 | sed s/_URL//` 
heroku pg:wait -a ${app}-staging 
heroku pg:promote ${new_db} -a ${app}-staging 
#Remove the old db 
if [ ! -z "${old_db}" ]l; then 
    heroku addons:remove ${old_db} -a ${app}-staging --confirm ${app}-staging 
fi