25 lines
897 B
SQL
25 lines
897 B
SQL
-- Add AUDIO question type and image_url support
|
|
|
|
-- 1. Extend question_type CHECK constraint to include AUDIO
|
|
ALTER TABLE questions
|
|
DROP CONSTRAINT IF EXISTS questions_question_type_check;
|
|
|
|
ALTER TABLE questions
|
|
ADD CONSTRAINT questions_question_type_check
|
|
CHECK (question_type IN ('MCQ', 'TRUE_FALSE', 'SHORT_ANSWER', 'AUDIO'));
|
|
|
|
-- 2. Add image_url column to questions
|
|
ALTER TABLE questions
|
|
ADD COLUMN IF NOT EXISTS image_url TEXT;
|
|
|
|
-- 3. Create question_audio_answers table for storing correct answer text
|
|
CREATE TABLE IF NOT EXISTS question_audio_answers (
|
|
id BIGSERIAL PRIMARY KEY,
|
|
question_id BIGINT NOT NULL REFERENCES questions(id) ON DELETE CASCADE,
|
|
correct_answer_text TEXT NOT NULL,
|
|
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
);
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS uq_question_audio_answers_question_id
|
|
ON question_audio_answers(question_id);
|