Sha256: de02767abe502c977ed83dd9f0f0a211134f76b1f139be897687e1d7e9a37b1c

Contents?: true

Size: 537 Bytes

Versions: 13

Compression:

Stored size: 537 Bytes

Contents

class AddQuestionSheetIdInRefs < ActiveRecord::Migration[4.2]
  def change
    add_column Fe::ReferenceSheet.table_name, :question_sheet_id, :integer

    # set initial question_sheet_id on all refs
    # NOTE: doing an update on a join query is a pain to do in both mysql and postgres
    # and since there's not that many reference questions, this should be fine
    Fe::ReferenceQuestion.all.each do |rq|
      Fe::ReferenceSheet.where(question_id: rq.id).update_all(question_sheet_id: rq.related_question_sheet_id)
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
fe-2.1.5 db/migrate/20151021184250_add_question_sheet_id_in_refs.rb
fe-2.1.4 db/migrate/20151021184250_add_question_sheet_id_in_refs.rb
fe-2.1.3 db/migrate/20151021184250_add_question_sheet_id_in_refs.rb
fe-2.1.2 db/migrate/20151021184250_add_question_sheet_id_in_refs.rb
fe-2.1.1 db/migrate/20151021184250_add_question_sheet_id_in_refs.rb
fe-2.0.8 db/migrate/20151021184250_add_question_sheet_id_in_refs.rb
fe-2.0.6 db/migrate/20151021184250_add_question_sheet_id_in_refs.rb
fe-2.0.5 db/migrate/20151021184250_add_question_sheet_id_in_refs.rb
fe-2.0.4 db/migrate/20151021184250_add_question_sheet_id_in_refs.rb
fe-2.0.3 db/migrate/20151021184250_add_question_sheet_id_in_refs.rb
fe-2.0.2 db/migrate/20151021184250_add_question_sheet_id_in_refs.rb
fe-2.0.1 db/migrate/20151021184250_add_question_sheet_id_in_refs.rb
fe-2.0.0 db/migrate/20151021184250_add_question_sheet_id_in_refs.rb