Class: ActsAsVotableMigration

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/acts_as_votable/migration/templates/active_record/migration.rb

Class Method Summary collapse

Class Method Details

.downObject



17
18
19
# File 'lib/generators/acts_as_votable/migration/templates/active_record/migration.rb', line 17

def self.down
  drop_table :votes
end

.upObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/generators/acts_as_votable/migration/templates/active_record/migration.rb', line 2

def self.up
  create_table :votes do |t|

    t.references :votable, :polymorphic => true
    t.references :voter, :polymorphic => true

    t.boolean :vote_flag

    t.timestamps
  end

  add_index :votes, [:votable_id, :votable_type]
  add_index :votes, [:voter_id, :voter_type]
end