This commit is contained in:
2026-04-12 18:54:59 +07:00
parent 28e866a64e
commit ec3d400e8a
71 changed files with 7888 additions and 333 deletions

33
supabase/schema.sql Normal file
View File

@@ -0,0 +1,33 @@
-- ============================================================
-- Schema: English Learning App (TOEIC Focus)
-- Run this FIRST before seed.sql
-- ============================================================
-- TOEIC questions (Part 17)
CREATE TABLE IF NOT EXISTS questions (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
part INT NOT NULL CHECK (part BETWEEN 1 AND 7),
type TEXT,
content TEXT NOT NULL,
options JSONB NOT NULL DEFAULT '[]', -- ["A. ...", "B. ...", "C. ...", "D. ..."]
answer TEXT NOT NULL, -- "A" | "B" | "C" | "D"
explanation TEXT,
audio_url TEXT, -- Part 14 (listening)
image_url TEXT, -- Part 1 (photos)
created_at TIMESTAMPTZ DEFAULT now()
);
-- TOEIC vocabulary (6 topics)
CREATE TABLE IF NOT EXISTS vocab (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
word TEXT NOT NULL,
phonetic TEXT,
meaning_vi TEXT NOT NULL,
topic TEXT NOT NULL CHECK (topic IN ('Business', 'Office', 'Travel', 'Finance', 'HR', 'Marketing')),
example TEXT,
created_at TIMESTAMPTZ DEFAULT now()
);
-- Indexes for common query patterns
CREATE INDEX IF NOT EXISTS idx_questions_part ON questions(part);
CREATE INDEX IF NOT EXISTS idx_vocab_topic ON vocab(topic);