Sha256: 7e99d4f40cc4c7dcc5bda92887ca1123104576799dca28fcf887335e51aa4fbb

Contents?: true

Size: 754 Bytes

Versions: 5

Compression:

Stored size: 754 Bytes

Contents

class ThumbsUpMigration < ActiveRecord::Migration
  def self.up
    create_table :votes, :force => true do |t|
      t.boolean    :vote, :default => false
      t.references :voteable, :polymorphic => true, :null => false
      t.references :voter,    :polymorphic => true
      t.timestamps
    end

    add_index :votes, ["voter_id", "voter_type"],       :name => "fk_voters"
    add_index :votes, ["voteable_id", "voteable_type"], :name => "fk_voteables"

    # If you don't want to enforce "One Person, One Vote" rules in the database, comment out the index below.
    add_index :votes, ["voter_id", "voter_type", "voteable_id", "voteable_type"], :unique => true, :name => "uniq_one_vote_only"
  end

  def self.down
    drop_table :votes
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
thumbs_up-0.3.1 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.3.0 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.2.3 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.2.2 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.2.1 lib/generators/thumbs_up/templates/migration.rb