Upgrade Heroku Postgres DB plan
In pratical ways you can do this to upgrade your postgres database plan:
heroku config
// It will show current database URL HEROKU_POSTGRESQL_COPPER_URL: postgres://xxxddxxdx:[email protected]:5432/xdfdsxdxxxx HEROKU_POSTGRESQL_SILVER_URL: postgres://fasdfsad:[email protected]:5432/sdfasdfdasfds // Default database set DATABASE_URL: postgres://fasdfsad:[email protected]:5432/dsfsdf
Create a new database
heroku addons:create heroku-postgresql:hobby-basic
(but I recommend that you go in server resource section and click Edit Addon and add pgsql and change plan from Free to your required plan)Run these commands to prevent database updates:
heroku maintenance:on
andheroku ps:scale worker=0
Copy current db to new db:
heroku pg:copy DATABASE_URL HEROKU_POSTGRESQL_COPPER_URL --app prod-test
Note:
DATABASE_URL = It is config veriable which point default current db HEROKU_POSTGRESQL_COPPER_URL = This is config variable for which db I just created prod-test = It is my APP name
Promote new database (Make new db as default db)
heroku pg:promote HEROKU_POSTGRESQL_COPPER_URL
Re-enable worker/dynos
heroku ps:scale worker=1
andheroku maintenance:off
remove old database
heroku addons:remove HEROKU_POSTGRESQL_SILVER_URL
There is a document on Heroku's site for doing exactly this: Upgrade Heroku postgres with pgbackups.
In short, the steps are as follows:
- setup a new new basic database
- Prevent updates (set maintence mode on)
- Capture your backup
- Restore the backup to the new database
- promote your new database
- make your app active
These are also the same steps to follow if you decide to go to a production plan.