Today I Learned

3 posts about #heroku

Using multiple commands on heroku CLI

Need to use multiple heroku CLI commands one after another and don’t want to type -a foo-bar-baz every time?

Type export HEROKU_APP=foo-bar-baz in terminal and then just happily run heroku command on foo-bar-baz application.

heroku pg:backups:capture -a foo-bar-baz

# is equivalent to:

export HEROKU_APP=foo-bar-baz
heroku pg:backups:capture

PS. After that you might want to unset HEROKU_APP to remove variable.

Downgrading Heroku PG database

Accidentally I’ve provisioned paid plan for PG database. To downgrade such a database you need to:

# safety measures
heroku maintenance:on

# create a new database, new url will be given, for me it was: HEROKU_POSTGRESQL_ORANGE_URL
heroku addons:create heroku-postgresql:hobby-dev 

 # copy current db to ORANGE db

# make new database active

# ... and we are back
heroku maintenance:off

After promotion old database was renamed to PINK then I removed it from heroku panel.

There is also other strategy for downgrade but it does not work for free plan: docs