2012-06-08 13 views

Respuesta

7

Sí, puede crear una horquilla directamente desde un DB de aplicaciones a otro. Para ello obtener el valor de su DATABASE_URL de su aplicación primaria luego usarlo en el siguiente comando:

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

perfecto, gracias – Alex

+0

para obtener el postgres: // url, ejecutar $ heroku config y coge la línea DATABASE_URL (o HEROKU_POSTGRESQL_color_URL) –

3

Agregando a la respuesta de Craig, aquí está a script by freeformz lo que hace todo el trabajo.

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 
Cuestiones relacionadas