File size: 967 Bytes
e46d575
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# MathMind AI β€” Database Setup

## Steps

1. Go to your **Supabase Dashboard β†’ SQL Editor**
2. Run the scripts **in order**:
   - `01_schema.sql` β€” creates all 6 tables + triggers
   - `02_rls.sql` β€” enables Row Level Security
   - `03_seed.sql` β€” inserts 5 badge definitions

## Tables Created

| Table | Purpose |
|-------|---------|
| `profiles` | Student grade + streak (extends auth.users) |
| `sessions` | One row per tutor session |
| `practice_attempts` | Practice problem responses |
| `test_results` | Mini-test scores and pass/fail |
| `badges` | Badge definitions |
| `student_badges` | Badges earned by each student |

## Notes

- **RLS is enabled** β€” students can only read/write their own data
- **Service role key** used by FastAPI backend bypasses RLS (server-side only β€” never expose to client)
- **Auto-trigger** creates a `profiles` row (grade=8 default) on every new signup
- Student must update their grade in the app after signup