Spaces:
Running
Running
Download db/007_mentoring.sql from lilyjeongwon/math-tutor: direct link, hf CLI and curl.
- Browser
- Download file 2.58 kB
-
https://huggingface.co/spaces/lilyjeongwon/math-tutor/resolve/main/db/007_mentoring.sql
- Command line
-
hf download hf://spaces/lilyjeongwon/math-tutor/db/007_mentoring.sql
-
curl -L -o 007_mentoring.sql https://huggingface.co/spaces/lilyjeongwon/math-tutor/resolve/main/db/007_mentoring.sql
2.58 kB
| -- ===================================================================== | |
| -- 007_mentoring.sql : νκΆλ λ 'λ©ν ' κΈ°λ₯ (κ°λ₯΄μΉλ©° λ°°μ°κΈ°) | |
| -- | |
| -- νλ μΌ | |
| -- 1) mentor_optin : νμμ΄ "μ΄ λ¨μ λ©ν λ‘ λμ€κ²μ"λ₯Ό μΌ°λμ§ (κ²μλ λ¨μμ΄ μλ νμλ§ νλ©΄μ λ²νΌμ΄ 보μ) | |
| -- 2) class_settings : νκΈλ³ λ©ν μ°κ²° μΌκΈ°/λκΈ° (λ΄μΒ·κ΄λ¦¬μκ° κ΅μ¬ νλ©΄μμ λ°κΏ, κΈ°λ³Έμ μΌμ§) | |
| -- 3) mentoring_log : "μ΄ μΉκ΅¬μκ² λ°°μ μ΄μ" ν λ² = ν μ€ (λ°°μ΄ νμμ΄ λλ¦). λ©ν μ 'λ¨' κ³μ°μ μ | |
| -- | |
| -- κ°μΈμ 보: RLS λ₯Ό μΌκ³ μ μ± μ λ§λ€μ§ μμ΅λλ€. μ± μλ²(service_role)λ§ μ½κ³ μλλ€. (004 μ κ°μ λ°©μ) | |
| -- μ¬λ¬ λ² μ€νν΄λ μμ ν©λλ€. (Supabase > SQL Editor μμ μ€ν) | |
| -- μ΄ SQL μ μ€ννκΈ° μ μλ μ±μ μ μ λμν©λλ€(λ©ν κΈ°λ₯λ§ κΊΌμ§ κ²μΌλ‘ 보μ). | |
| -- ===================================================================== | |
| create table if not exists mentor_optin ( | |
| student_id uuid primary key references profiles(id) on delete cascade, | |
| opt_in boolean not null default false, | |
| updated_at timestamptz not null default now() | |
| ); | |
| create table if not exists class_settings ( | |
| class_id text primary key, -- "νλ -λ°" (μ: "1-10"), allowed_users κΈ°μ€ | |
| mentoring_on boolean not null default true, | |
| updated_by uuid references profiles(id) on delete set null, | |
| updated_at timestamptz not null default now() | |
| ); | |
| create table if not exists mentoring_log ( | |
| id uuid primary key default gen_random_uuid(), | |
| mentor_id uuid not null references profiles(id) on delete cascade, | |
| mentee_id uuid not null references profiles(id) on delete cascade, | |
| unit_id text not null, | |
| qid text, -- ν¨κ» νΌ λ¬Έν(source_ref) | |
| created_at timestamptz not null default now(), | |
| day date not null default ((now() at time zone 'Asia/Seoul')::date), | |
| check (mentor_id <> mentee_id) | |
| ); | |
| create index if not exists idx_mentoring_mentor on mentoring_log (mentor_id); | |
| create index if not exists idx_mentoring_mentee on mentoring_log (mentee_id); | |
| alter table mentor_optin enable row level security; | |
| alter table class_settings enable row level security; | |
| alter table mentoring_log enable row level security; | |
| grant select, insert, update, delete on mentor_optin to service_role; | |
| grant select, insert, update, delete on class_settings to service_role; | |
| grant select, insert, update, delete on mentoring_log to service_role; | |