Database entry not showing up on Heroku - ruby-on-rails

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

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>

How to rake db:migrate on a Heroku staging pipeline?

I've setup an app on Heroku, and I've now also set up a pipeline for staging. I did this by creating a fork of my production app on Heroku, then adding this to the app pipeline under the "staging" stage.
Before this (when I only had the app in production), I pushed updates to heroku from the CLI with git push heroku master. I could then update the database for new features with heroku run rake db:migrate.
However, I'm not sure how you would do this with a staging app in a pipeline? I tried using the --remote appendage but it doesn't recognise the app (I think because the --remote was pre pipelines?)
I have auto updates from git setup so that my app-staging always mirrors my git master, and I've just added a new feature which includes a table. The view on the staging site is now returning an error as I haven't run heroku run rake db:migrate on the staging site.
I obviously don't want to push these changes to production without know this new feature works. So how do you do it? Any ideas how to rake db:migrate the pipeline staging database? I can't find any guidance in the heroku manual either :/
Run
git remote -v
to see your remote name.
Assuming your staging remote name is staging, then:
heroku run rake db:migrate --remote staging
Read more

heroku run rake db:migrate failed: command not found

I'm a novie in heroku. When I was performing my CS169.1x homework2 (deploying an application) I ran into a problem with database filling using the following command: heroku run rake db:migrate. Here is terminal dump:
saasbook#saasbook:~/Documents/hw2_rottenpotatoes$ git pull heroku master
From heroku.com:afternoon-cove-7289
* branch master -> FETCH_HEAD
Already up-to-date.
saasbook#saasbook:~/Documents/hw2_rottenpotatoes$ git push heroku master
Everything up-to-date
saasbook#saasbook:~/Documents/hw2_rottenpotatoes$ heroku run rake db:migrate
heroku run rake db:migrate: command not found
saasbook#saasbook:~/Documents/hw2_rottenpotatoes$
What may be wrong? If there is error dump on heroku to check?
Have you installed the heroku gem? If you have heroku in the gemfile, you may need to do
bundle exec heroku run...
just to make sure you have heroku installed, what happens when you run:
$heroku help

Deploying Heroku app--updating my code?

This is a basic, stupid question, but I configured my Rails app to deploy on Heroku, and I'm able to open the application from my Heroku account, etc. But when I want to change my code, do I need to re-deploy the whole application? I tried just committing/pushing to heroku master, but I get the error "fatal: remote end hung up unexpectedly." What should I do instead?
Also: am I supposed to run db:migrate BEFORE deploying/pushing?
There is nothing stupid about a basic question, as everyone has to start somewhere.
The basic process with deploying a Rails app to Heroku is to:
Make changes
Add and Commit your changes ($ git add files_changed.rb & $ git commit -m "make changes")
Push your changes to Heroku ($ git push heroku master)
This then pushes your code to the remote Heroku repository and redeploys your Rails application. If you have made any database migrations, you need to run:
$ heroku run rake db:migrate
This runs db:migrate on your heroku app - see how that works? :)
Running rake db:migrate locally simply migrates your local development database.

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