1

I read a lot about it but i still can't get rid of one table that I have in my db:

create_table "votes", force: true do |t|
  t.integer  "votable_id"
  t.string   "votable_type"
  t.integer  "voter_id"
  t.string   "voter_type"
  t.boolean  "vote_flag"
  t.string   "vote_scope"
  t.integer  "vote_weight"
  t.datetime "created_at"
  t.datetime "updated_at"
end

add_index "votes", ["votable_id", "votable_type", "vote_scope"],
          name: "index_votes_on_votable_id_and_votable_type_and_vote_scope"  
add_index "votes", ["voter_id", "voter_type", "vote_scope"],
          name: "index_votes_on_voter_id_and_voter_type_and_vote_scope"

I don't have a migration that create this table. But I think this table comes from a previous installation of the acts_as_votable gem. But I might have deleted this migration manually...

I tried to drop_table as follows, but it's not working. Even if I have this migration file, the votes table is still there:

class DropVotesTable < ActiveRecord::Migration
  def up
    drop_table :votes
  end

  def down
    raise ActiveRecord::IrreversibleMigration
  end
end

What should I do to delete this table from my schema.rb file?

EDIT: solution

Even after running the migration the table was still in my schema.rb so I used the rails console:

rails c
ActiveRecord::Migration.drop_table(:votes)
rake db:migrate

And this table finally disappeared.

  • Do you have a migration which creates this table? Or these lines appear after you run `rake db:migrate`? – gotva Jul 03 '14 at 20:34
  • I think you are looking for something like this: http://stackoverflow.com/questions/3872586/how-to-delete-migration-files-in-rails-3 – Rodrigo Assis Jul 03 '14 at 21:18
  • I edited the code with more information about my migrations files – Jérémy Zaccherini Jul 03 '14 at 22:03
  • 1
    Have you run the migration? If so, what is the output that it produces? If it produces no output, then confirm that the VERSION (date/time stamp) of this migration file is not already contained in the `schema_migrations` table in your database -- if it is then attempting to migrate will not do anything. – pdobb Jul 03 '14 at 23:02
  • I fixed it using the rails console - I edited my question! Thanks @pdobb – Jérémy Zaccherini Jul 03 '14 at 23:24

0 Answers0