Insert Rails Migration Between Two Existing Migrations
===

I created the following migration:

<!-- language: ruby -->

    class FixVoteColumnName < ActiveRecord::Migration
        def change
            rename_column :votes, :post_id, :votable_id
            add_column :votes, :votable_type, :string
          end
        end

And then mistakenly created this migration, renaming the column again:

    class ChangeVoteTableColumns < ActiveRecord::Migration
      def change
        rename_column :votes, :post_id, :votable_id
      end
    end

This obviously raises an error upon running rake db:migrate:


    ==  FixVoteColumnName: migrating ==============================================
    -- rename_column(:votes, :post_id, :votable_id)
    rake aborted!
    An error has occurred, this and all later migrations canceled:
    
    Missing column votes.post_id

When I first saw this error, I simply deleted the second migration (as in, moved it to my Trash folder), ran rake db:migrate again, and moved on. After that point, I created 3 migrations and ran them successfully. 

When I pushed to Heroku, this proved problematic. Somehow, Heroku was still processing the deleted migration. I got it working by running heroku run rake db:schema:reload but I know that isn't a long-term solution.

I think what I need to do is move the second migration back into my db/migrate directory and inserting a migration between the two that renames :votable_id back to :post_id so that the second migration can run properly. I've could also run rake db:rollback, but since there have been a few migrations since the problematic migration, that might get messy.

Any ideas on how I can solve this responsibly? This is just a fun project so dropping the database isn't the end of the world, but I would like to learn how to do it the *right* way, if there is one.

