Problem with approach to configuration variable
So far, you can share the database between two applications in Heroku by copying the configuration variable DATABASE_URL first application to the second, only the first application will have the main connection (addition) to the database.
If you uninstall the first application, your database will disappear from the postgres control panel in Heroku. Although it seems that the second application will still be able to use the database. (Tested in 2015-10-25)
It is also worth noting that:
Heroku reserves the right to change the database URLs as necessary. If this happens, your additional connections will fail, and you will need to update the URLs accordingly.
This means that if Heroku decides to change the URL of your database, your new application will fail, and since the database will now disappear from your dashboard, you will not be able to get the new URL without approaching Heroku. (If at all.)
This means that there is a more internal relationship between the application and its database than just DATABASE_URL , and it might not be a better idea to use this as a mechanism for transferring.
Alternative Approach Using PGBackups
Heroku official documentation recommends using the free PGBackups add-on (which, frankly, you should always work anyway) to transfer data between Postgres instances. The tool uses its own tools pg_dump and pg_restore .
In particular, you can use the PG copy function described below:
PG copy uses PostgreSQL's built-in backup and recovery tools. Instead of writing the backup to disk, it transfers it by cable directly to the recovery process in the new database.
They conveniently provide you with the means to copy the database between applications with a single command and without any intermediate storage:
Alternatively, you can transfer data between databases that are connected to various applications.
To copy the source database to the target database, you will need to call pg: copy from the target application, referencing the source database.
Example:
heroku pg:copy source-application::OLIVE HEROKU_POSTGRESQL_PINK -a target-application
Where source-application is your existing stack, and target-application your new one. It does not apply to you, but it is worth mentioning that any existing data in the target-application database will be destroyed.
After that, you may need to promote the database in a new application like this:
heroku pg:promote HEROKU_POSTGRESQL_PINK