Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the correct way to copy data from a postgresql database in one app to a postgresql database in another app on heroku?

I have been following the documentation Heroku docs on the subject and have gone through this and tried variations on what it says to do to for

Direct database-to-database copies

I am convinced the docs are wrong or I have some setting or somthing wrong (do have admin access). I have also read some scattered things on SO that the command in the heroku CLI for how to do this has changed.

When I run this command (using the credentials for my heroku DB)

heroku pg:copy sushi::ORANGE GREEN --app sushi-staging

After I confirm the message:

WARNING: Destructive action ▸ This command will remove all data from

and confirm. Then I get an error that says:

Heroku PostgreSQL database must be source or target

What is the corrrect way to copy data from a postgresql database in one app to a postgresql database in another app on heroku?

like image 898
Dan Avatar asked Jan 23 '18 09:01

Dan


People also ask

How do you copy data from one database to another database in Postgres?

PostgreSQL copy database within the same server: PostgreSQL makes it simple to do so using the CREATE DATABASE statement as follows: Syntax: CREATE DATABASE target_database WITH TEMPLATE source_database; This statement copies the source_database to the target_database.


1 Answers

This worked for me:

heroku pg:copy [origin databasee URI] DATABASE_URL --app [app-name]

like image 132
alayor Avatar answered Oct 13 '22 00:10

alayor