Commit 52ab5e9
docs: correct schema reference against the live database (#530)
Verified docs/DATABASE_SCHEMA.md table by table against the local
database (which matches cloud — see below) and fixed what was wrong.
lib/database.types.ts needed no change: regenerating it from the local
DB produces a byte-identical file apart from the __InternalSupabase
header that `--linked` adds. Local migrations, cloud schema and the
committed types are all in sync.
Columns that did not exist as documented (each one silently breaks a
query or a .rpc() call):
- enrollments: still listed product_id/subscription_id and their CHECK
constraint, all dropped by the entitlements migration. entitlements
itself was absent from the doc entirely despite being the source of
truth for course access.
- plans: documented `name`, `interval`, `stripe_*_id`; actually
plan_name, duration_in_days, provider_*_id.
- subscriptions: documented `status`, `stripe_subscription_id`,
`created_at`; actually subscription_status, provider_subscription_id,
created.
- exercise_completions: documented student_id + submission/is_correct/
ai_feedback; actually user_id + completed_by/score.
- exercises: documented initial_code/solution_code/test_cases — none
exist.
- products: documented stripe_product_id/stripe_price_id; actually
provider_*_id.
- exam_questions: documented a `sequence` column that does not exist.
- exam_submissions: documented is_reviewed; actually review_status.
- gamification: documented 12 tables including gamification_daily_caps
and gamification_challenges, neither of which exists. There are 10.
- transactions: documented one composite unique index; there are three
(product-shaped, plan-shaped, provider_charge_id idempotency).
- currency_type: documented usd/eur; there are eight values.
- RPCs: handle_new_subscription is missing _start_date,
save_exam_feedback takes nine p_-prefixed args not six, award_xp's
signature was wrong in CLAUDE.md and AI_AGENT_GUIDE.md.
- Table count was "65+" everywhere; it is 116.
Also adds what the doc had no way to keep right on its own:
- "Verifying this document" — the diff/introspection commands to check
any claim here against the database in one line.
- "Tables without tenant_id" — the full 55-table list plus the query
that regenerates it. Filtering these by tenant_id errors the whole
query, which is a recurring source of blank pages.
- docs/README.md rewritten: it indexed six files that do not exist
(API_ROUTES.md, RLS_POLICIES.md, four features/*.md) and advertised
the project as "Phase 5 complete, Phase 6 next".
- docs/ACTUAL_SCHEMA.md now carries a stale banner — it claims to be
the actual live schema and is the first thing a name-search finds,
but it is a February 2026 snapshot documenting dropped columns.
Claude-Session: https://claude.ai/code/session_01853LDokPbhv9Kg9Ctz9DB5
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent be37e8f commit 52ab5e9
7 files changed
Lines changed: 357 additions & 165 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
127 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
128 | 129 | | |
129 | | - | |
| 130 | + | |
130 | 131 | | |
131 | 132 | | |
132 | 133 | | |
| |||
151 | 152 | | |
152 | 153 | | |
153 | 154 | | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
159 | 158 | | |
160 | 159 | | |
161 | 160 | | |
162 | | - | |
163 | | - | |
| 161 | + | |
| 162 | + | |
164 | 163 | | |
165 | 164 | | |
166 | 165 | | |
| |||
174 | 173 | | |
175 | 174 | | |
176 | 175 | | |
177 | | - | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
178 | 181 | | |
179 | 182 | | |
180 | 183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
4 | 15 | | |
5 | 16 | | |
6 | 17 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
302 | 302 | | |
303 | 303 | | |
304 | 304 | | |
305 | | - | |
306 | | - | |
307 | | - | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
308 | 310 | | |
309 | 311 | | |
310 | | - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
311 | 317 | | |
312 | 318 | | |
313 | 319 | | |
314 | 320 | | |
315 | | - | |
316 | | - | |
317 | | - | |
| 321 | + | |
| 322 | + | |
318 | 323 | | |
319 | | - | |
320 | | - | |
321 | | - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
322 | 327 | | |
323 | | - | |
324 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
325 | 331 | | |
326 | 332 | | |
327 | 333 | | |
| |||
377 | 383 | | |
378 | 384 | | |
379 | 385 | | |
380 | | - | |
| 386 | + | |
381 | 387 | | |
382 | 388 | | |
383 | 389 | | |
| |||
0 commit comments