Class: CreateVoterLoveTables
- Inherits:
-
ActiveRecord::Migration
- Object
- ActiveRecord::Migration
- CreateVoterLoveTables
- Defined in:
- lib/generators/voter_love/templates/migration.rb
Class Method Summary collapse
Class Method Details
.down ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/generators/voter_love/templates/migration.rb', line 18 def self.down remove_index :votes, :column => [:votable_type, :votable_id] remove_index :votes, :column => [:voter_type, :voter_id] remove_index :votes, :name => "unique_voters" drop_table :votes end |
.up ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/generators/voter_love/templates/migration.rb', line 2 def self.up create_table :votes do |t| t.string :votable_type t.integer :votable_id t.string :voter_type t.integer :voter_id t.boolean :up_vote, :null => false t. end add_index :votes, [:votable_type, :votable_id] add_index :votes, [:voter_type, :voter_id] add_index :votes, [:votable_type, :votable_id, :voter_type, :voter_id], :name => "unique_voters", :unique => true end |