I am using the heroku pipeline. I set up my two apps. One for staging, one for production. Both use "production" as the environment variable.
If I run heroku run rails c
I can access the console on my staging app. The heroku website, allows to run a console in the production app as well, but only with the predifined heroku run
part. Which means if for whatever reason I need to run a more fundamental command (for example heroku pg:reset
; I know I know), I can't.
So is there a way to specify which heroku app I want to run the commands at? Something like heroku pg:reset production-app-name
maybe?
I am using cloud9 as an IDE, not sure if that makes a difference.
Yes, you got it almost right, just add --app
before the app-name
:
$ heroku pg:reset --app production-app-name
In fact, if you have more than one app configured (run heroku apps
to list them), you will get an error; for example, try running a safer command:
$ heroku logs
If you have more than one app, the output will be:
▸ Error: Multiple apps in git remotes
▸ Usage: heroku logs --remote production
▸ or: heroku logs --app production-app-name
▸
▸ Your local git repository has more than 1 app referenced in git remotes.
▸ Because of this, we can't determine which app you want to run this command against.
▸ Specify the app you want with --app or --remote.
▸
▸ Heroku remotes in repo:
▸ production (production-app-name)
▸ staging (staging-app-name)
▸
▸ https://devcenter.heroku.com/articles/multiple-environments