Sha256: 32f4cd9abf6d08397e0a3cf418ea83088625614118f1ffb0f949f897d660090f

Contents?: true

Size: 849 Bytes

Versions: 4

Compression:

Stored size: 849 Bytes

Contents

class RemoveOptionIdFromQuestions < ActiveRecord::Migration
  class Tasuku::Taskables::Question < ActiveRecord::Base; end

  class Tasuku::Taskables::Question::Answer < ActiveRecord::Base
    self.table_name = 'tasks_taskables_question_answers'
    has_many :votes
    belongs_to :option
  end

  class Tasuku::Taskables::Question::Vote < ActiveRecord::Base
    self.table_name = 'tasks_taskables_question_votes'
    belongs_to :option
    belongs_to :answer
  end

  class Tasuku::Taskables::Question::Option < ActiveRecord::Base
    self.table_name = 'tasks_taskables_question_options'
    belongs_to :vote
    belongs_to :option
  end

  def up
    Tasuku::Taskables::Question::Answer.all.each do |answer|
      answer.votes.create option: answer.option
    end

  	remove_column :tasks_taskables_question_answers, :option_id, :integer
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tasuku-1.1.0 db/migrate/20140512131526_remove_option_id_from_questions.rb
tasuku-1.0.1 db/migrate/20140512131526_remove_option_id_from_questions.rb
tasuku-0.1.1 db/migrate/20140512131526_remove_option_id_from_questions.rb
tasuku-0.1.0 db/migrate/20140512131526_remove_option_id_from_questions.rb