Class: CreateVotes

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

Class Method Summary collapse

Class Method Details

.downObject



16
17
18
# File 'lib/generators/templates/migrations/create_votes.rb', line 16

def self.down
  drop_table :votes
end

.upObject



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

def self.up
  create_table :votes do |t|
    t.column :vote, :boolean, :default => false
    t.column :created_at, :datetime, :null => false
    t.column :voteable_type, :string, :limit => 25, :default => "", :null => false
    t.column :voteable_id, :integer, :default => 0, :null => false
    t.column :user_id, :int
    t.column :ip_address, :string, :limit => 25
  end
  
  add_index :votes, [:user_id, :voteable_id, :voteable_type], :name => "index_votes"
  add_index :votes, [:ip_address], :name => "index_votes_ip_address"
end