Sha256: 996ea7f1abe944ab7a9ab77ca412d153c7f579e08c67cb05df0e2fc9a5d9e8c6

Contents?: true

Size: 758 Bytes

Versions: 11

Compression:

Stored size: 758 Bytes

Contents

class ThumbsUpMigration < ActiveRecord::Migration
  def self.up
    create_table :votes, :force => true do |t|

      t.boolean    :vote,     :default => false,    :null => 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

11 entries across 11 versions & 1 rubygems

Version Path
thumbs_up-0.6.10 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.6.9 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.6.8 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.6.7 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.6.6 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.6.5 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.6.4 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.6.3 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.6.2 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.6.1 lib/generators/thumbs_up/templates/migration.rb
thumbs_up-0.6.0 lib/generators/thumbs_up/templates/migration.rb