in Ruby on Rails

Fixing schema.rb

I had an interesting problem recently. I tried installing a gem for private messages (which created a bunch of tables in my schema.rb) and found out it did not work.

So I did a git revert and was left with a bunch of files I didn’t want (in particular migrations that no longer worked). I deleted the migrations, along with removing the gem, etc, etc. Unfortunately when I ran rake db:migrate again the tables keep reappearing in the schema.rb. After trying rake db:rollback and a few other things I found a solution.

Using this will set all of your tables based directly on your schema rather than your migrations. This is useful if you have a bunch of old migrations that you no longer use just sitting in your /db/migrate/ folder.

Write a Comment