Class: BallotBoxCreateVotes

Inherits:
ActiveRecord::Migration
  • Object
show all
Defined in:
lib/generators/ballot_box/templates/migrate/create_votes.rb

Class Method Summary collapse

Class Method Details

.downObject


31
32
33
# File 'lib/generators/ballot_box/templates/migrate/create_votes.rb', line 31

def self.down
  drop_table :ballot_box_votes
end

.upObject


2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/generators/ballot_box/templates/migrate/create_votes.rb', line 2

def self.up
  create_table :ballot_box_votes do |t|
    # Voter
    t.string  :voter_type, :limit => 40
    t.integer :voter_id
    
    # Voteable
    t.string  :voteable_type, :limit => 40
    t.integer :voteable_id
    
    # User info
    t.integer :ip_address, :limit => 8
    t.string  :user_agent
    t.string  :referrer
    t.string  :browser_name, :limit => 40
    t.string  :browser_version, :limit => 15
    t.string  :browser_platform, :limit => 15

    # Vote value
    t.integer :value, :default => 1
  
    t.timestamps
  end

  add_index :ballot_box_votes, [:voter_type, :voter_id]
  add_index :ballot_box_votes, [:voteable_type, :voteable_id]
  add_index :ballot_box_votes, :ip_address
end