-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsupabase_schema.sql
More file actions
67 lines (58 loc) · 2.44 KB
/
supabase_schema.sql
File metadata and controls
67 lines (58 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
create table
if not exists public.users (
id bigint generated by default as identity primary key,
username text not null unique,
email text unique,
hashed_pw text not null,
created_at timestamptz not null default now ()
);
create table
if not exists public.sections (
id bigint generated by default as identity primary key,
user_id bigint not null references public.users (id) on delete cascade,
section_id text not null,
completed boolean not null default true,
completed_at timestamptz not null default now (),
unique (user_id, section_id)
);
create table
if not exists public.bookmarks (
id bigint generated by default as identity primary key,
user_id bigint not null references public.users (id) on delete cascade,
bm_id text not null,
title text not null,
path text not null,
added_at timestamptz not null default now (),
unique (user_id, bm_id)
);
create table
if not exists public.quiz_scores (
id bigint generated by default as identity primary key,
user_id bigint not null references public.users (id) on delete cascade,
quiz_id text not null,
score integer not null,
total integer not null,
taken_at timestamptz not null default now (),
unique (user_id, quiz_id)
);
create table
if not exists public.solver_history (
id bigint generated by default as identity primary key,
user_id bigint not null references public.users (id) on delete cascade,
expression text,
result text,
created_at timestamptz not null default now ()
);
create index if not exists sections_user_id_idx on public.sections (user_id);
create index if not exists bookmarks_user_id_idx on public.bookmarks (user_id);
create index if not exists quiz_scores_user_id_idx on public.quiz_scores (user_id);
create index if not exists solver_history_user_id_idx on public.solver_history (user_id);
-- This project uses backend-managed auth, not Supabase Auth.
-- The backend validates its own JWT and talks to Supabase from server-side code.
-- If RLS is enabled on these custom tables, anon/publishable keys will be blocked.
-- For local development, disable RLS on these app-owned tables.
alter table public.users disable row level security;
alter table public.sections disable row level security;
alter table public.bookmarks disable row level security;
alter table public.quiz_scores disable row level security;
alter table public.solver_history disable row level security;