How to use a different database for Heroku review apps? How to use a different database for Heroku review apps? heroku heroku

How to use a different database for Heroku review apps?


To do that, create the app.json file at the root of your project instead of using the heroku dashboard. In this file, you can specify what environment variables to inherit from the parent.

From the heroku docs:

"env": { "INHERIT_THIS_CONFIG_VAR": { "required": true }, "DONT_INHERIT_THIS_CONFIG_VAR": "production" },

This allows you to specify which database you want to use for the review app. Looking at the documentation of the heroku postgres addon (i assume you're using postgres):

As part of the provisioning process, a DATABASE_URL config var is added to your app’s configuration. This contains the URL your app uses to access the database.

So the database_url config variable will be created by the adddon. You simply need to not put it in the app.json file, and it will be created automatically.


Check that you do not have the DATABASE_URL set in the Pipeline Settings CONFIG VARS in Heroku either.. if it is set there, then it seems the Review App will use that as the DB link and not the one created when the Review App is created.