This script keeps Heroku review apps database read-write for configured parent apps, even if they exceed 10k lines.
-
Deploy this code to a Heroku app:
-
Configure the Heroku Scheduler to start
ruby heroku_review_apps_awakener.rb
whenever you like (we do it everyday at 5am and 9pm UTC) -
Enjoy always-read-write database for your review apps 🎉
With Heroku Pipeline, every GitHub pull request can generate a review app.
A common trick is to:
-
attach the parent app database as
PARENT_DATABASE
using:heroku addons:attach DATABASE PARENT_DATABASE
-
make it available to review apps from
app.json
:"env": { "PARENT_DATABASE_URL": { "required": true } }
-
copy the parent database content on each provisioned review app database (again, from
app.json
):"scripts": { "postdeploy": "pg_dump ${PARENT_DATABASE_URL} | psql ${DATABASE_URL}" }
The problem is that review apps can only use Heroku Postgres free plan, which has a maximum allowed capacity of 10,000 lines. If you exceed it, Heroku disrupts it after 24 hours by setting it read-only ðŸ˜
The solution is to force a PG backup restore (heroku pg:backups restore
) to reset the 24 hours read-write grace period.
Please let us define larger plans for review apps.
This project is developed by Alpine Lab and released under the terms of the MIT license.