How to Upgrade or Downgrade Heroku Postgres adon plan

If you are using Heroku and Postgres adon in your project, by the time you may want to upgrade or downgrade Heroku Postgres adon plan based upon your project's database size decrease or increase with time.
Although you can follow Heroku documentation for the purpose:
Changing the Plan or Infrastructure of a Heroku Postgres Database

But I wish to introduce you to another way to upgrade or downgrade the Heroku PostgreSQL Database adon plan.

In this process we have 3 steps to follow:
1. Add additional Heroku Postgres adon with the desired plan (you want to switch) using the below command:

    heroku addons:create heroku-postgresql:adon-plan --app your-appname

Where `adon-plan` can be replaced with the desired plan from the plan list and `your-appname` with your application name.

2. Now copy your database from the old Postgres adon to the newly added Postgres adon.
    
    heroku pg:copy HEROKU_POSTGRESQL_MAUVE_URL HEROKU_POSTGRESQL_PINK_URL -a your-appname

Here `HEROKU_POSTGRESQL_MAUVE_URL` and `HEROKU_POSTGRESQL_PINK_URL` are system URL names of source and destination databases respectively.
If you want to know where you should find these database URL names? you can open the resources tab in your app. Here when you click on `Attached as DATABASE` (or attachments) dropdown. Here you will see the system name of your database and add the suffix `URL` to it.


Here for first for the top database name is `DATABASE_URL` and for the bottom one, it is `HEROKU_POSTGRESQL_PINK_URL`.

3. After your database is completely copied to the new Postgres adon, you can change the default database i.e. promote the new Postgres adon database as the default database using the command:

    heroku pg:promote HEROKU_POSTGRESQL_PINK_URL -a your-appname

Now you are using your desired Heroku adon plan for your database project. You can now delete old Postgres adon to avoid additional billing charges.

So using the above 3 steps you can upgrade or downgrade the Heroku Postgres adon pricing plan.

Comments

Popular posts from this blog

Using Virtual Columns in Laravel - Accessors and Appends

How to Show Cookie Policy Consent or GDPR Popup in Laravel using Cookie.

Postman Collection Run - How to Test File Uploading API on CircleCi or Jenkins