When running my RoR app in Heroku shows this error:
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
Checking the heroku logs, this shows http://pastebin.com/yTWtRMVD
My main page is https://salty-stream-26420.herokuapp.com/ and my callback URL is https://salty-stream-26420.herokuapp.com/auth/twitter/callback in OmniAuth.
It runs in Cloud9 perfectly but not in Heroku. What is wrong?
Thank you, Alex.
This:
2016-05-03T13:47:23.544506+00:00 app[web.1]: PG::UndefinedTable: ERROR: relation "submissions" does not exist
suggests to me that you have to simply migrate your database on the remote server.
Try running heroku run rake db:migrate
You will have to create environment variables in the config/database.yml file for the username, password and database name
Those same environment variables need to be defined under
Heroku login >> application >> settings >> reveal config vars
By default you will get a DATABSE_URL something as
postgres://wwwbirawxqwmws:7bef28c02299c9c6054a646b5ce19276bbab52feca6692dac8305b32dbd7d36c#ec2-81-XX-XXX-X26.compute-1.amazonaws.com:5432/d6n59y5r09ko99
where wwwbirawxqwmws is USER
and 7bef28c02299c9c6054a646b5ce19276bbab52feca6692dac8305b32dbd7d36c is PASSWORD
and d6n59y5r09ko99 is the DATABASE
These three variables needs to be assigned in the heroku config, then you will be able to run
heroku run rake db:create
heroku run rake db:migrate
Related
I have some data in my postgresql database that I entered using a very simple rails app. I deployed it to heroku and now am trying to send my local database to heroku because its very empty right now.
At first I thought doing heroku run rake db:migrate would actually do this but turns out it only creates tables in heroku?
These are the steps I took to transfer my local database to heroku.
1: heroku run rake db:migrate ( I did this to create tables which should be empty right?)
2: heroku pg:push my_db DATABASE_URL --app my-herokuapp-98989 (the actual syntax to transfer database)
Here, it said
"Remote database is not empty. Please create a new database or use heroku pg:reset"
4: heroku pg:reset DATABASE
"WARNING: Destructive action" "postgresql-amorphous-59192 will
lose all of its data" "To proceed, type my-herokuapp-98989 or
re-run this command with --confirm my-herokuapp-98989
5: my-herokuapp-98989
"Resetting postgresql-amorphous-59192... done"
After this I try to open my app but it gives off an error saying
"ActionView::Template::Error (PG::UndefinedTable: ERROR: relation
"drinks" does not exist" "2017-07-29T04:50:20.697828+00:00
app[web.1]: LINE 1: SELECT "drinks".* FROM "drinks""
"drinks" is the name of my table and I think it is giving this error because I just reset my database so there is no table or columns and rows?
So again I try pushing my database to heroku and it just freezes at this point
6: heroku pg:push my_db DATABASE_URL --app my-herokuapp-98989
"heroku-cli: Pushing my_db ---> postgresql-amorphous-59192"
...and it freezes here
What am I doing wrong? Please help.
are you sure it's freezing? or its just loading, because you need to upload the dumpfile to heroku.
you also can try this command
heroku pg:backups:restore 'https://url/where/heroku/can/download/yourdbdump.dump' DATABASE_URL
more about import export you can read here. https://devcenter.heroku.com/articles/heroku-postgres-import-export#import
I have a rails app running on the Elastic Beanstalk service.
When I deploy my app, some pages didn't work. I think the problem is that after I delete a model and create a new model with the same name but different schema, the database didn't reset.
On local, I can run rake db:drop, rake db:create, rake db:migrate to reset the database. However, how to reset the database on EB?
to run it manually, you can simply eb ssh your environment and issue the rake commands. Alternatively if you don't need that db, simply recreate the environment from the beanstalk web console, which will recreate the db.
i think you have to delete also structure.rb file manual from your rails application and let it create again by using rake db:migrate
I am currently doing the Ruby on Rails tutorial by Michael Hartl. Somewhere along the way I messed up my database. In my database file there is only 1 user, by the name of Bob.
Locally in cloud9 IDE, when I do 'rails console' and then do Users.first, I get a user with a name of "Bob".
However when I do 'heroku rails run console' and do Users.first, I get a user with a different name. (I probably changed the name somewhere along the way)
How do I get Heroku to see the correct local database file again? Should I clear the heroku database, then use pg:pull to pull the local sql database to heroku?
Not sure if you've gotten to Chapter 9 yet but section 9.3.2 of the current book deals with creating sample users. This is done through the db/seeds.rb file.
Running $ bundle exec rake db:reset then resets your DB followed by $ bundle exec rake db:seed to fill it with your new data.
You can run the same procedure on your production application with:
heroku pg:reset DATABASE
heroku run rake db:migrate
heroku run rake db:seed
It is, of course, also possible to transfer data between local and production databases with tools such as heroku-pg-transfer but that's a little advanced if you're only starting out, and I think somewhat unnecessary if you only have one user to transfer over.
Hope this helps.
You can use yaml_db gem to dump your local data to file and then upload it to heroku.
On your development machine:
rake db:data:dump
Then commit changes, push to heroku and run:
heroku run rake db:data:load
so i've successfully installed Harrys Prelauncher on Heroku (https://github.com/harrystech/prelaunchr)
and to export my collected emails into a csv i need to run this command (bundle exec rake prelaunchr:create_winner_csvs)
is there any way to run that command through pgadmin or some other program?
or is the only way for me to download my heroku database and run the command locally? also how and what would i need to do this?
i'm pretty new to rails and postgresql and would really appreciate if someone could help me out!
Because the rake task creates files locally you can't just run it on heroku via heroku run rake. You can however set up your local database.yml to connect to your heroku postgresql instance and run the rake task locally.
Run heroku pg:credentials to get the required database values.
Fill in the production environment of config/database.yml with the values you obtained from step 1 (for the value of 'database' in the yml file, use dbnmae from step 1)
Test your connection with RAILS_ENV=production rails db. This should drop you into a psql console.
Run the rake task. RAILS_ENV=production bundle exec rake prelaunchr:create_winner_csvs
The files will save locally in lib/assets as indicated by the documentation.
From within the directory of the project you can use
heroku run rake prelaunchr:create_winner_csvs
You should probably create a UI form in to your application.
On click on export CSV, it should run background job on heroku (Using delayed jobs).
heroku run rake prelaunchr:create_winner_csvs
Use send_data ruby method. To send your generated and dumped data file on to your browser.
Download the file on to your local system from running heroku instance.
Hope this will resolve your problem.
Cheers!!!
I ran into this problem recently while developing the Prelaunchr campaign for a client. Assuming you have a local version of your app and are using Postgres Copper in Heroku, you can "pull" your Heroku database down to your local machine, set that as your development database in database.yml, and run the rake task from your local app, which should now have the same database as your heroku version. Here is the command to pull the db (subbing out name_for_database & heroku_app_name with your own):
heroku pg:pull HEROKU_POSTGRESQL_COPPER_URL name_for_database --app heroku_app_name
Make sure to restart your local server to see the new database info populated.
Hey
I'm afraid I should ask a rookie question :
After push my app to heroku. I got error of no database
This is the command I use
heroku rake db:migrate
My app can run locally with no problem, but I notice the database file only in development.
and my test evironment only use rails server and localhost:3000
anyone tell me how to make the database in production mode in heroku.
Thanks
here's the heroku log file:
here's the logs
Started GET "/drummers/1" for
221.9.247.14 at Sat Dec 18 06:17:40 -0800 2010 Processing by DrummersController#show as HTML
Parameters: {"id"=>"1"} Completed in
167ms
ActiveRecord::RecordNotFound (Couldn't
find Drummer with ID=1):
app/controllers/drummers_controller.rb:11:in
`show'
I think it may due to the datebase,config file, become I use sqlite3 in local test, and all the migration file is development prefix,
It's not telling you that you have no Database.
It's telling you that it can't find a specific record
(Couldn't find Drummer with ID=1):
It's likely that you have code that's doing Drummer.find(1) and that doesn't exist on your production environment.
Recommend you either:
create a seeds file (heroku rake db:seed) rails cast
push your entire database to heroku (heroku db:push) [make sure you understand this will wipe out your production database]
Heroku creates a database for each application deployed to it (no need to run heroku rake db:create. Here are the commands you should be using to deploy a Rails application to Heroku:
git init
git add .
git commit -m "initial import"
heroku create
git push heroku master
heroku rake db:migrate
heroku open
I believe Heroku creates a new database.yml for you on deploy if you have no production according to the Docs.