Sha256: b3c5a16ea12cb34c4d2421cf4b90347bb54af634186807af8c8de1b87ee614e2

Contents?: true

Size: 766 Bytes

Versions: 3

Compression:

Stored size: 766 Bytes

Contents

class CreateMakeVoteableTables < ActiveRecord::Migration
   def self.up
     create_table :votings do |t|
       t.string :voteable_type
       t.integer :voteable_id
       t.string :voter_type
       t.integer :voter_id
       t.boolean :up_vote, :null => false

       t.timestamps
    end

    add_index :votings, [:voteable_type, :voteable_id]
    add_index :votings, [:voter_type, :voter_id]
    add_index :votings, [:voteable_type, :voteable_id, :voter_type, :voter_id], :name => "unique_voters", :unique => true
  end

  def self.down
    remove_index :votings, :column => [:voteable_type, :voteable_id]
    remove_index :votings, :column => [:voter_type, :voter_id]
    remove_index :votings, :name => "unique_voters"
    
    drop_table :votings
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
make_voteable-0.1.1 lib/generators/make_voteable/templates/migration.rb
make_voteable-0.1.0 lib/generators/make_voteable/templates/migration.rb
make_voteable-0.0.2 lib/generators/make_voteable/templates/migration.rb