Rails rake db: Rollback to Heroku doesn't work. Now I cannot add new migrations

I have an application that works fine locally. At one point, I tried to set the Act As Taggable attribute, which created a series of migration files. I have now rolled back locally after we voted against using this gem, but after deploying to heroku, it looks like 5 of these migration files have loaded into hero.

Then I ran

`heroku run rake db:migrate'

      

Now I am getting this error

'uninitialized constant AddTaggingsCounterCacheToTags::ActsAsTaggableOn/app/db/migrate/20141107010718_add_taggings_counter_cache_to_tags.acts_as_taggable_on_engine.rb:6:in `up'

      

Now I don't need "AddTaggingsCounterCacheToTags", but I definitely need a migration that should have run after that.

Any advice on how I can remove this from the production / heroku server? How can I remove only certain migrations and keep the most recent migration I did?

Thank!

+3


source to share


1 answer


Good. I understood.

The problem was that after deleting the files locally, they were still present on git. This process was to remove the migration that caused the error, and after that I could complete all migrations after just a penalty. The commands below ...



   git rm [filename]
   git commit -a -m "removed the migrations causing the error from git too"
   git push origin master
   git push heroku master
   heroku run rake db:migrate

      

There is currently an issue with an empty / unneeded table in the database, but the important thing is that I can keep adding migrations and my newest features now work correctly in production! Hooray!

+1


source







All Articles