Guest User

Untitled

a guest
May 27th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  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
Add Comment
Please, Sign In to add comment