class TadpollMigration

Public Class Methods

down() click to toggle source
# File lib/generators/tadpoll/migration/templates/active_record/migration.rb, line 27
def self.down
  drop_table :votes
  drop_table :polls
  drop_table :options
end
up() click to toggle source
# File lib/generators/tadpoll/migration/templates/active_record/migration.rb, line 2
def self.up
  create_table :votes do |t|
    t.references :voter, :polymorphic => true
    t.belongs_to :poll, index: true
    t.belongs_to :option, index: true

    t.timestamps
  end

  create_table :polls do |t|
    t.string :name

    t.timestamps
  end

  create_table :options do |t|
    t.string :name
    t.belongs_to :poll, index: true

    t.timestamps
  end

  add_index :votes, [:voter_id, :voter_type]
end