-- Fix wrong FK on `orac_question_options`: options must reference the parent question via `question_id`,
-- not via `question_options_id` (AUTO_INCREMENT), which caused:
-- "Cannot add or update a child row: ... FOREIGN KEY (`question_options_id`) REFERENCES `orac_questions` (`question_id`)"
--
-- Run once on your MySQL database (same pattern as `orac_answers` → `orac_questions`).
-- Connect to the `hse` schema (e.g. `mysql -u root -p hse < migrations/002_orac_question_options_fix_fk.sql`).

ALTER TABLE `orac_question_options`
  DROP FOREIGN KEY `orac_questions_orac_question_options_option`;

ALTER TABLE `orac_question_options`
  ADD CONSTRAINT `orac_questions_orac_question_options_question`
  FOREIGN KEY (`question_id`)
  REFERENCES `orac_questions` (`question_id`)
  ON DELETE CASCADE
  ON UPDATE CASCADE;
