Class: InstallBallotVoteMigration

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

Instance Method Summary collapse

Instance Method Details

#changeObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/generators/ballot/install/templates/active_record/migration.rb', line 4

def change
  create_table :ballot_votes do |t|
    t.references :votable, polymorphic: true
    t.references :voter, polymorphic: true

    t.boolean :vote, null: false, default: true
    t.string :scope
    t.integer :weight

    t.timestamps null: false
  end

  add_index :ballot_votes, i(voter_id voter_type scope)
  add_index :ballot_votes, i(votable_id votable_type scope)
end