Heroku ignoring recent migrations - ruby-on-rails

I just ran heroku rake db:migrate and three of my most recent migrations are being ignored completely. I've pushed everything to Heroku and github but it's like Heroku doesn't think these even exist.
git status reveals nothing amiss, and my Github repo contains the migration files in the right place.
What's wrong?

Running "heroku restart" from the command line sometimes fixes the issue too.

From what you've said it should work..
If you're completely stuck, you could always try pulling your production database from heroku, migrating on your local machine and then pushing the database back up to heroku?
At the very least you might be able to see what's going on in your database at least?
http://blog.heroku.com/archives/2009/3/18/push_and_pull_databases_to_and_from_heroku/

Related

Heroku missing last 4 migrations. Migration files do exist in Git

Heroku is missing the last 4 migrations for a RoR app. The files exist in the git repository and are named/numbered accordingly. I tried manually forcing that version to run, but it simply can't find it. I tried this:
heroku run rake db:migrate:up VERSION=20190328183515
and the result was
ActiveRecord::UnknownMigrationVersionError: No migration with version number 20190328183515
Trying to redeploy from local to heroku stage does nothing since it states everything is up to date. I tried touching the files in case they weren't included in the deployed files, but looking at the git repository confirmed that's not the case.
Any ideas on what's going on here and how to get heroku to recognize that it is missing 4 migration files that still need to be processed? Resetting the database is not an option. I tried rolling back the database and running the migrations again but it stops on the migration file for 3/27/2019

heroku app not being properly updated?

I'm new to the web development scene, so sorry if my lack of knowledge bugs you
When i run my local code using rails s and testing on my own server, the front end is not the same as the local one.
My first attempt was to initially fix some snippet of code, then use git push, then git push heroku master.
I've tried deleting the app and pushing fresh new code again, and it still doesn't work
I've tried heroku restart, and no changes also
Any suggestions?
edit
pictures for clarity
top is local, bottom is heroku server
Further to #RSB's comment, you'll probably find that your CSS is not being compiled properly
To fix this, you'll have to perform a precompile when you deploy. However, Heroku already does this, so probably won't be an issue
The best thing to do is eliminate any potential issues -
#config/environments/production.rb - config.serve_static_assets = true
local - rake assets:precompile RAILS_ENV=production
git add .
git commit -a -m "CSS Test"
git push heroku master
Try running this command in your project folder
heroku run rake assets:precompile

how to relaunch rails app on heroku

My app runs properly locally and has a crash when it runs on Heroku. The app does fine until I run a new_post_path call. I tried git push to see if a change to the new.html.erb file or the _form.html.erb file was the issue - but I think during the last push to heroku - my database may have taken a hit. At the time I was adding a t.text field (longtext) and it seems to be the issue.
So I wanted to roll back or totally re-start at heroku. But I have not found anyway to do it. Since this is not near production yet. Is there anyway to just create a new instance at heroku and push up to it?
Again, local version runs perfect. Thanks in advance for any ideas.
I would say there are several ways to handle this problem
restarting heroku
Run $ heroku restart in the rails dir. Sometimes I believe in magic.
debugging
Use $ heroku log to debug what is causing the error.
migrate database
Perhaps you made a database change in local rails, while heroku rails didn't.
Run heroku run rake db:migrate
drop database and remigrate database
See this thread. Sometimes old migration might be in conflict with current migration. Do a clean migration, if the data in your database isn't important.
recreate heroku instance
run $ heroku apps:destroy –app appname and replace appname with your appname. Then delete the current heroku remote repository location from git. git remote rm heroku. Then recreate heroku. run $ heroku create. go through pushing your code and migrating database like usual.
Relaunching might be the least of your problems, so I suggest a few things:
Review this Heroku article on releases, including the Heroku rollback feature.
Add the PG Backups add-on to your app.
I also recommend using something like the exception_notification gem in combination with the SendGrid add-on, so that you can get an email with details on the error as well.

rails database migration - multiple migrations have the version number x

Ok, I have stuffed up my migrations. I tried to sort it by deleting duplicates, sorting the schema.rb etc but I don't think I have done it properly.
When I try to deploy to heroku, or rather heroku run rake db:migrate, I get
Multiple migrations have the version number 20130307005437
The migrate works fine on localhost but not heroku.
Unfortunately when I look for migration no 20130307005437, it's not there in my db/migrate.
How can I find it to sort the problem?
While this file might not be visible within your directory listing, I suspect that there might already be a file within your Git repository, which is what is causing this error from appearing on Heroku and not locally.
Please ensure that you've only got one migration inside that Git repo with that number.

Rails/Heroku : db:push runs correctly but does not create the DB

I've been having problems yesterday with Heroku shared Postgres DB. It looks like my db is not correctly 'pushed' to my heroku DB.
Configuration
Using 'pg' gem for both development and production environments.
Using Heroku's 'shared-database' add-on.
Running Rails 3.1.1.
What I'm trying to do
Push my source code to Heroku and then synchronize my postgres DB with Heroku's one. No problem for the source itself, but I can't get my DB up and running.
What I've tried so far
1: Source code push : git push heroku master. OK. This works.
2: Then I try to run : heroku db:push. Seems to be running normally, no error, the schema is sent to Heroku, the different tables are correctly detected and seem to be sent as well :
3: Let's check it out, is everything allright ? heroku info :
Doh ! The database is still empty (and therefore I get DB-related errors when accessing dynamic pages). Can't understand what's happening, I've spent time on this issue yesterday evening but only been mpessing with Heroku for a little while and never encountered this issue. Any clues ?
I'm not convinced that the Database size figure is a live figure. Here's a clean deployment of an app to Heroku and the output of heroku info at each stage. The first run is post application creation, the second after a push of the code, the third after a heroku db:push.
The database was uploaded before the third output and the application is running however the DB:size is not reporting the figure.
Is your application actually erroring because the database isn't present?
The problem is in the commit process.
You should run manually after each commit from your console :
heroku run rake db:migrate
Enjoy
daniel

Resources