Shuffle/supabase/README.md
cschlaefke 317634dac5
Some checks are pending
CI / flutter (push) Waiting to run
CI / supabase (push) Waiting to run
CI / supabase-tests (push) Waiting to run
chore: initial project kit
2026-11-02 12:14:09 +01:00

27 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Supabase – Datenbank für Shuffle
## Inhalt
| Pfad | Zweck |
|---|---|
| `migrations/` | Schema, Trigger und RLS-Policies für R1 (17 Tabellen, 2 Views). Nur additiv ändern, nie bestehende Dateien editieren. |
| `tests/database/` | pgTAP-Tests: Struktur-Regeln und Zugriffsrechte je Bereich. |
| `seed.sql` | Beispieldaten nur für die lokale Entwicklung. |
## Lokal starten und testen
```bash
supabase start # lokales Backend
supabase db reset # Migrationen + Seed einspielen
supabase test db # alle pgTAP-Tests ausführen
```
## Regeln
- Jede Tabelle hat `id` (uuid, PK), `created_at`, `updated_at` und Row Level Security.
- `updated_at` setzt ein Trigger; `id` und `created_at` sind nach dem Anlegen unveränderlich.
- Fremdschlüssel nur dort, wo Tabellen in Beziehung stehen, benannt `<Zieltabelle>_id`.
- Rechte werden explizit vergeben (erst alles entziehen, dann gezielt gewähren).
- Admin-Rolle kommt aus `app_metadata.role = 'admin'` im JWT, nie aus `user_metadata`.
## Noch nicht enthalten
- Storage-Buckets und -Policies für Avatare und Spielbilder.
- Edge Functions (BGG-Import, Konto löschen).
- Selbst-Hosting-Setup auf Hetzner (ADR-0002, Aufgabe für `devops`).