How to specify an app's name while running a Heroku command? - ruby-on-rails

I've just run heroku run rails db:migrate to add some new columns to my production tables after git push heroku master but I receive the error
Simons-MBP:gourmet_coffee Simon$ heroku run rake db:migrate
▸ Error: Could not find git remote stagegcl in /Users/Simon/gourmet_coffee
▸ remotes: heroku staging
So it's clearly trying to run on my staging app. How do I change this so it's my production app?

If you have multiple apps for the same project, you can use --app or -a flag to specify the name of the app.
heroku run rails db:migrate --app <the-name-of-your-app>

Related

Database entry not showing up on Heroku

I am developing my first Rails app, and I have made some database entries that are showing up in the development environment, but not in the production environment (Heroku). I have run
git add
git commit
git push origin master
git push heroku master
rake db:migrate
in the terminal.
$ heroku create
$ git push heroku master
After running these commands, to get the application’s database to work, you’ll also have to migrate the production database:
$ heroku run rake db:migrate
$ heroku open
if this doesn't work please show your logs.
you just need to run
heroku run rake db:migrate

How to run DB migrations that effect only on heroku fork app

On heroku I create fork app using heroku fork --from sourceapp --to targetapp
By this I copy an existing application and Heroku Postgres data.
Now I push some migrations on fork app using git push forked master.
How I run these migrations on heroku that it effect only heroku-fork app.
When I run heroku run rake db:migrate , is it effect both or only fork one?
When you have multiple applications associated with the same codebase, Heroku will ask you which application you want to run the command on.
You'll specify that with the -a or --app flag, so for example
heroku run rake db:migrate --app <APPNAME>
This will allow you to run commands on the fork app or the source app.

heroku pg:psql "no app specified"

I am trying to access my Heroku database with the usual command heroku pg:psql but I am getting :
! No app specified.
! Run this command from an app folder or specify which app to use with --app <app name>
Although I am running it from the app folder. If I try heroku pg:psql --app APPNAME I get :
Resource not found
Has anything changed recently?
Alright I just needed to update my heroku toolbelt.

"heroku run rake db:migrate" issue

Folks, I am following Ruby on Rails Tutorial and working on the DemoApp in Chapter 2. My env is :
Win 7
Ruby 1.9.3
Rails 4.0.2
I have deployed the demo app (under directory demo_app) locally and have tested it out locally as well. I did push it to Heroku using
c:\rails_projects\demo_app heroku create --stack cedar
c:\rails_projects\demo_app git push heroku master
the app gets deployed to heroku.
When I run: heroku run rake db:migrate
I get the error:
No app specified. Run this command from an app folder or specify which app to use with --app APP.
I have run it with heroku run rake db:migrate --app demo_app
but get the same error.
Not sure what to do.
Heroku will have given your app a random name when you created the app. Run heroku apps from the terminal to get the name of your app, then heroku run rake db:migrate --app your_app_name.
Assuming the name of your app is robot.
On your terminal, heroku run rake db:migrate --app=robot

Heroku and Rails: transferring db to staging and db:migrate

I've been working on a Heroku app for several months. We've recently set up a staging server and occasionally sync the staging db with the production db. The three main commands in use are:
$ heroku pgbackups:capture --app myapp
$ heroku pg:reset DATABASE --app myapp-staging --confirm myapp-staging"
$ heroku pgbackups:restore DATABASE `heroku pgbackups:url --app myapp` --app myapp-staging
The problem is that after running the third command, I need to run heroku run rake db:migrate --app myapp-staging. We have a few dozen migrations now, including some that refer to Ruby classes that we've deleted or renamed.
This causes the migrations to fail to fully run. What's the solution here? Should I delete the old migrations that fail and commit these changes to the git repo?
Re-running this script fixed the error, so it seems like the schema should just copy over. For anyone seeing a failing migration like I did, the pgbackups:restore command probably failed for you, so re-run that.
You can also checkout the transfer command now as part of pgbackups .. see this post
How do I transfer production database to staging on Heroku using pgbackups? Getting error

Resources