Sha256: 52130c0ae97f4cbf1ad488339b5d5a7d264ce6064c35c241fcfec8969e6accc3

Contents?: true

Size: 613 Bytes

Versions: 3

Compression:

Stored size: 613 Bytes

Contents

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.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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
acts_as_votable-0.7.1 lib/generators/acts_as_votable/migration/templates/active_record/migration.rb
acts_as_votable-0.7.0 lib/generators/acts_as_votable/migration/templates/active_record/migration.rb
acts_as_votable-0.6.0 lib/generators/acts_as_votable/migration/templates/active_record/migration.rb