Sha256: 94f7c7acbfd9a54d771e91843973200813a3fa3fe39b9220ac32ffd18e5aeb2f

Contents?: true

Size: 753 Bytes

Versions: 14

Compression:

Stored size: 753 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]
    add_index :votes, [:voteable_id, :voteable_type]

<% if options[:unique_voting] == true %>
    # Comment out the line below to allow multiple votes per voter on a single entity.  
    add_index :votes, [:voter_id, :voter_type, :voteable_id, :voteable_type], :unique => true, :name => 'fk_one_vote_per_user_per_entity'
<% end %>
  end

  def self.down
    drop_table :votes
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
thumbs_up-0.5.7 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.5.6 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.5.5 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.5.4 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.5.3 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.5.2 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.5.1 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.5.0 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.4.6 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.4.5 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.4.4 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.4.3 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.4.1 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.4 lib/generators/thumbs_up/templates/migration.rb