heroku run rake db:migrate doesn't find app - ruby-on-rails

I've tried everything - I always get Timeout waiting dyno or App not found.
can someone please help me use the right syntax or something - what in the world could I be doing wrong??
Here are some links that haven't helped:
https://twitter.com/viktorbenei/status/456913389928054784
heroku : run rake db:migrate error
https://devcenter.heroku.com/articles/one-off-dynos#timeout-awaiting-process
https://devcenter.heroku.com/articles/dynos
https://www.google.com/search?espv=2&q=how+to+deploy+rails+app+to+heroku+rake+db&oq=how+to+deploy+rails+app+to+heroku+rake+db&gs_l=serp.3...1923.3702.0.3978.8.8.0.0.0.0.258.775.0j4j1.5.0.msedr...0...1c.1.64.serp..5.3.520.88zR1b0gS6c
https://devcenter.heroku.com/articles/rake
Heroku run rake db:migrate results in no change in the database, app restarted several times

the problem was that I was trying to do this at work. I thought that it was communicating with the server because it would say things like app not found but it actually wasn't. when I tried this at home it worked fine.

Related

Rails Application fails with 500 for any page on Home Controller - Heroku Only

I am having troubles figuring out what is wrong for this. My app is working perfectly in development on cloud9, but my production app on Heroku is not working. Any page I try to load from HomeController throws up the 500 error, so I imagine it has something to do with a before action for that controller, but I removed it and still get the error.
I have run bundle install, I have run rake db:migrate.
I'm not really sure what else I am missing. Here is my code for the HomeController. When I visit a page linked to an action on my "ProductController" everything works fine, no error.
EDIT
Removed my code because it wasn't related in the end.
You probably forgot migrations, which can explain why it fails everywhere.
Run:
heroku run rake db:migrate
If it doesn't change, check the logs while refreshing the page:
heroku logs -t
You'll see the error.
Other explanation: you forgot to add API keys in the env variables on heroku.

Rails: ActiveRecord::PendingMigrationError

I need some help getting my Cloud 9/Rails environment working again for an online course I'm working on through Upskill. I ran into a problem with one section and ended up rolling back to a previous commit. However, since I did that, I've run into some database errors I haven't been able to resolve.
Here is what I get when I try to access my app:
ActiveRecord::PendingMigrationError
Migrations are pending. To resolve this issue, run: bin/rails db:migrate RAILS_ENV=development
I've tried the suggested method to resolve it, but it hasn't worked, nor have a dozen other suggestions I've found in other threads with a similar message.
Below is what I see when I run rails db:migrate:status. So I believe maybe it has something to do with the third item there.
Status Migration ID Migration Name
up 20170331144924 Create contacts
up 20170406172755 Devise create users
down 20170410151911 Add devise to users
I am really lost but just hoping to get back to where I was so I can continue with the lessons. Thank you.
What worked for me was:
rake db:test:purge
rake db:test:prepare
Have you tried running a specific migration which is down like this? Ref
rake db:migrate:up VERSION=20170410151911

IntelliJ Idea/Rubymine push to Heroku running db:migrate

I'm using IntelliJ Idea with the Rubymine plugin, and Heroku plugin, and I'm a bit stumped when it comes to pushing an app to Heroku. I can set it up and actually push the app: off it goes, and launches successfully. But even before I did that I was expecting it to fail because I couldn't find anyway of getting it to do a db:migrate. And so it proved: the app is launched but of course it fails pretty much immediately because there's no DB.
I've looked on the forums, google etc but nothing. Is this something that can only be done from the command line? I would have expected an IDE to be what it says on the tin: Integrated. So I feel I'm missing something. The Run configuration works as I've said, and the Heroku log has no errors, but I need a way to tell it to run the db:migrate before launching.
Any ideas?
The answer is that it is something that it doesn't do - confirmed by IntelliJ. So in this case, one needs to push the app to Heroku, drop to the command line and run the migration there: heroku run rake db:migrate.
I raised a feature request so this may be something that can be added in the future.
I haven't figured out how to do this automatically as part of the RubyMine/JetBrains Heroku Plugin. But you can cobble this together from other sources.
Start with this gist that creates rake tasks for Heroku operations provided by this answer to a similar question:
Then create a new run configurations for each Rake task that you will be using at some point. You will need at minimum push and migrate. But the other tasks might interest you.
Then create a new compound run configuration calling the Rake tasks you created in step 2 in the correct order.
Step 2 and 3 can be consolidated by creating one rake task for migration, and adding a before rake task to push. But that's kind of counter intuitive.
Note: that this approach does require you to have the Heroku CLI installed and configured with valid credentials.

Trying to deploy Sinatra app to Heroku with psql database, getting load error

I'm not the most experienced of developers so please excuse me if this is a stupid question.
I am trying to deploy a Sinatra app that uses PostgreSQL as it's database. My application works locally but then when I try to deploy to Heroku, I get this error:
Screenshot of Terminal after I try to push to heroku master
I have no idea what is going on. I don't think I'm requiring anything incorrectly b/c I would think that it wouldn't work locally if that were the case. I tried running the bit of code that says "bundle exec rake -P" but it didn't do anything as far as I know. I thought maybe I'd have to create a database and migrate it since I did that with a Rails app I was working on, but this is in Sinatra, so not sure if you have to do something entirely different.
It apparently deployed to Heroku, but when I run heroku open, it doesn't work. I just get a page that says to try again later and look at the log.
Any ideas on how to solve this issue?

ruby page on Heroku comes up with error: 'we're sorry but something went wrong'

Hi in the last week pushed a ROR rake task to prod and then ran the rake task to update some table fields in heroku.
Everything was seemed fine at the time but this week I did something that I hadn't done in the previous week of creating a new practice or editing one gives an error of 'we're sorry but something went wrong'
The error message I get from running --tail in the terminal says
Completed 500 internal server error in 34ms
ActionView::Template::Error (undefined method 'practices' for nil:NilClass);
This is my production application.
In the staging application I don't get this error.
The 2 environments are supposed to be the same.
Is a migration needed? or failing that how could I work out what is going wrong.
thanks
maggs
Run this command and try
heroku run rake db:migrate
Database
The 2 environments are supposed to be the same. Is a migration needed?
It depends on if you're using the same database in production & development
By default, Heroku gives you a blank PGSQL database, or you can override their DATABASE_URL config variable to use your own db:
heroku config:set DATABASE_URL=mysql://your_database
Recommendation
For now, I would recommend performing a heroku run rake db:migrate on your Heroku database, as this will provide the right data structure for your app
The real problem, though, is you're calling practices on an undefined object (nil:class). To ensure this is not a problem, you either need some logic such as:
unless #variable.nil?
# do something
end
or you need to ensure you're working with the correct data

Resources