This commit is contained in:
2014-07-21 23:41:44 +05:30
parent e8252fbf16
commit 44a0dc2f98
13 changed files with 119 additions and 24 deletions

View File

@@ -0,0 +1,27 @@
class ActsAsVotableMigration < ActiveRecord::Migration
def self.up
create_table :votes do |t|
t.references :votable, :polymorphic => true
t.references :voter, :polymorphic => true
t.boolean :vote_flag
t.string :vote_scope
t.integer :vote_weight
t.timestamps
end
if ActiveRecord::VERSION::MAJOR < 4
add_index :votes, [:votable_id, :votable_type]
add_index :votes, [:voter_id, :voter_type]
end
add_index :votes, [:voter_id, :voter_type, :vote_scope]
add_index :votes, [:votable_id, :votable_type, :vote_scope]
end
def self.down
drop_table :votes
end
end