CREATE TABLE IF NOT EXISTS public.user_progress (
id bigint GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
user_id uuid REFERENCES auth.users(id) ON DELETE CASCADE NOT NULL,
subject text NOT NULL,
question_id integer NOT NULL,
last_result text NOT NULL,
attempts integer DEFAULT 1 NOT NULL,
wrong_count integer DEFAULT 0 NOT NULL,
updated_at timestamptz DEFAULT now() NOT NULL,
UNIQUE(user_id, subject, question_id)
);
ALTER TABLE public.user_progress ENABLE ROW LEVEL SECURITY;
CREATE POLICY "Users manage own progress"
ON public.user_progress FOR ALL
USING (auth.uid() = user_id)
WITH CHECK (auth.uid() = user_id);
3Paste your Project URL and anon key below (Project Settings β API)