heroku : run rake db:migrate error - ruby-on-rails

Running `rake db:migrate` attached to terminal... failed
! Multiple apps in folder and no app specified.
! Specify app with --app APP.
I get the above error in my terminal when I try to run rake db:migrate can anyone please help?

As the error clearly states, you need to specify which app you wish to run the command for. If you are inside of the project directory, you shouldn't need to specify the app. If you are outside of your projects folder run the command like so:
heroku run rake db:migrate --app <your-app-name>

I've had this problem crop up where it wasn't related to heroku at at. If you really want to see, open up your .git/config file
For example, I was with staging and found I had the 2nd remote. Deleting this from my .git/config file fixed everything.
[remote "staging"]
url = git#heroku.com:site-stage.git
fetch = +refs/heads/*:refs/remotes/staging/*

Related

How to specify an app's name while running a Heroku command?

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>

Heroku run rake db:migrate

I did the following steps for deploying app and migrating my database:
git add -A
git commit -m "add changes"
git push heroku master
heroku run rake db:migrate
In console I see next:
Running `rake db:migrate` attached to terminal... up, run.9234
== 20150713191218 CreateMovies: migrating =================
-- create_table(:movies)
-> 0.0379s
== 20150713191218 CreateMovies: migrated (0.0381s) ============
heroku restart
But heroku run rake db:migrate does not work. When I run my app, my database is empty. I don't understand why. I don't see any errors.
And I'm sorry, that I repeat this question. I saw that people already asked about this problem, but no advice helped me.
try heroku run rake db:migrate RAILS_ENV=production
To populate your database automatically with rake task you need to use the command RAILS_ENV=production rake db:seed(this will populate your production database) and have a seed file in place. But I guess that was not really what you were looking for

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 rake command

I'm trying to push my Rails app to Heroku, and I'm at the point where I'm trying to create/migrate the database, but I cannot get the rake command to run. Here's the message I'm getting:
$ heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.2439
bash: rake: command not found
I spent a lot of time getting Postgres set up on my local machine, and it's working fine (was able to run rake commands without issue, and the app is running locally), but I don't know why I'm getting this error when I try to migrate the heroku database.
Figured it out. Turns out I had an error when I tried to deploy the app to Heroku, so it was never deployed. I didn't realize this because I was trying to push a branch that was not the "master" branch to heroku, thinking it would be fine. I wasn't getting any errors on that push, but that's because heroku won't try to deploy anything other than the "master" branch. Once I pushed the "master" branch, I got a bunch of pre-compile errors. Once those were cleaned up, I the app was deployed properly and I was able to run the rake commands.
Long story short, make sure your app successfully deployed before trying to run rake commands.

Heroku rake error in terminal

Seem to be getting the following error in my terminal. Any reason why this is not working?
Running `rake` attached to terminal... up, run.7822
!
! Error connecting to process
You're probably bumping up against connectivity issues.
Ensure it is, in fact, a network issue by trying to connect to heroku's servers rendezvous.heroku.com:5000 and s1.runtime.heroku.com:5000. If so, you'll need to figure out where along the route you're getting snagged.
You can also try running your rake command in detached mode as a temporary workaround:
heroku run:detached rake some:task

Resources