class CreateQuestionSections < ActiveRecord::Migration[7.0]
  def change
    create_table :question_sections do |t|
      t.references :interview_question, null: false, foreign_key: true
      t.references :master_section, null: false, foreign_key: true

      t.timestamps
    end

    # Prevent the same section from being assigned to a question twice
    add_index :question_sections, %i[interview_question_id master_section_id], unique: true, name: "idx_qs_on_question_and_section"
  end
end
