~acesuares/qspell/trunk

« back to all changes in this revision

Viewing changes to vendor/plugins/vote_fu/generators/vote_fu/templates/migration.rb

  • Committer: Ace Suares
  • Date: 2009-10-07 06:16:20 UTC
  • Revision ID: ace@suares.an-20091007061620-j39st30s42edy61t
 * voting with vote_fu

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
class VoteFuMigration < ActiveRecord::Migration
 
2
  def self.up
 
3
    create_table :votes, :force => true do |t|
 
4
      t.boolean    :vote, :default => false
 
5
      t.references :voteable, :polymorphic => true, :null => false
 
6
      t.references :voter,    :polymorphic => true
 
7
      t.timestamps      
 
8
    end
 
9
 
 
10
    add_index :votes, ["voter_id", "voter_type"],       :name => "fk_voters"
 
11
    add_index :votes, ["voteable_id", "voteable_type"], :name => "fk_voteables"
 
12
 
 
13
    # If you want to enfore "One Person, One Vote" rules in the database, uncomment the index below
 
14
    # add_index :votes, ["voter_id", "voter_type", "voteable_id", "voteable_type"], :unique => true, :name => "uniq_one_vote_only"
 
15
  end
 
16
 
 
17
  def self.down
 
18
    drop_table :votes
 
19
  end
 
20
 
 
21
end