Remove Supabase
The database moved to a container of our own; the platform is gone. This takes out what was left of it — and, where the leftovers were load bearing, moves rather than deletes. Moved, not deleted: supabase/migrations/ -> db/migrations/ the schema's source of truth supabase/build-org.ts -> scripts/build-org.ts lib/supabase/types.ts -> lib/types.ts 52 import sites repointed The bookkeeping needed care. It lived in `supabase_migrations.schema_migrations`, and simply renaming the schema would have left the runner facing an empty table: it would have called all 67 migrations pending and replayed them against a database that is long since current. So the runner now creates `migrationen.schema_migrations` and, once, copies the old rows across — guarded so a second run does nothing and a fresh database skips it entirely. Only then does migration 20260907100000 drop the old schema. Deleted: the CLI config, the seed, the historical schema/function dumps (nothing read them), scripts/umzug-von-supabase.sh (the move is done), and both Supabase packages plus the CLI. Nothing in the application imported them — the build now succeeds with no environment variables at all, which is the proof. Integration tests: six of them signed in through Supabase Auth and asserted against the anon key and the service role. That model is gone, so the tests were not portable — they are deleted. session-context and employee-status-filter already ran on pg and are untouched; om-reporting is ported to a direct connection because it guards a real risk (the reporting line rule exists twice, once in SQL and once in TypeScript). CI: the integration job started a Supabase stack. It now runs a postgres service, applies deploy/db-init and every migration to an empty database — that was the valuable part, and it still holds — then checks that a second run is a no-op, which is what proves the bookkeeping works. Docs: security-review.md audited a service-role key, a cookie adapter and auth.users, none of which exist. Restating findings about removed components would suggest today's system had been reviewed; it has not. It now records what was removed and says a fresh review is due. data-model.md was already marked obsolete and described the pre-OM schema; azure-migration.md was a plan for a route not taken. Both deleted. Verified: npm ci, typecheck, lint, 445 tests, build — all clean without the packages. Integration tests skip cleanly with no database. Migration SQL and the runner are reviewed but NOT executed: no Docker here, and the old instance no longer resolves. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
63
README.md
63
README.md
@@ -24,11 +24,13 @@ auf explizit aktivierte HR-Benutzer:innen beschränkt (siehe
|
||||
`node_modules/next/dist/docs/` konsultieren; sie sind maßgeblich, ältere
|
||||
Anleitungen im Netz beschreiben teils überholte APIs.
|
||||
- React 19, TypeScript
|
||||
- Supabase (Postgres, Auth, RLS) — Datenhaltung liegt vollständig in
|
||||
Supabase, nicht im Next.js-Prozess.
|
||||
- PostgreSQL, angesprochen über Kysely und `pg` — die Datenhaltung liegt in
|
||||
der Datenbank, nicht im Next.js-Prozess. Der Zugriff läuft ausschliesslich
|
||||
über `withUser()` (`lib/db/`), das den Sitzungskontext setzt.
|
||||
- Auth.js gegen Microsoft Entra ID — keine eigenen Passwörter.
|
||||
- Tailwind CSS v4
|
||||
- Vitest — Unit- (Node), Komponenten- (jsdom) und Integrationstests
|
||||
(gegen ein lokales Supabase)
|
||||
(gegen eine erreichbare Datenbank)
|
||||
|
||||
## Setup
|
||||
|
||||
@@ -38,14 +40,14 @@ cp .env.example .env.local # Werte eintragen, siehe unten
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Für lokale Supabase-Entwicklung (statt gegen ein Cloud-Projekt):
|
||||
Für eine lokale Datenbank genügt der Container aus `docker-compose.yml`:
|
||||
|
||||
```bash
|
||||
supabase start # startet lokalen Postgres/Auth/Studio-Stack
|
||||
docker compose up -d db
|
||||
docker compose run --rm migrate # spielt db/migrations/ ein
|
||||
```
|
||||
|
||||
`supabase/config.toml` und `.env.test.local` sind bereits auf die
|
||||
Standard-Ports der lokalen Supabase-CLI abgestimmt.
|
||||
Danach zeigt `DATABASE_URL` in `.env.local` auf diese Datenbank.
|
||||
|
||||
## Umgebungsvariablen
|
||||
|
||||
@@ -77,8 +79,9 @@ selbst spricht. Ein Docker-Abbild ist damit umgebungsneutral: einmal gebaut,
|
||||
| `npm run lint` | ESLint (`eslint-config-next`, Flat Config) |
|
||||
| `npm run typecheck` | `tsc --noEmit` |
|
||||
| `npm run test` | Vitest, Unit-Tests (`tests/unit/**`) |
|
||||
| `npm run test:integration` | Vitest gegen eine echte (lokale) Supabase-Instanz — braucht `supabase start` und `.env.test.local` |
|
||||
| `npm run test:integration` | Vitest gegen eine erreichbare Datenbank; überspringt sich ohne `DATABASE_URL` |
|
||||
| `npm run test:e2e` | Playwright |
|
||||
| `npm run migrate` | Ausstehende Migrationen einspielen (`--dry-run`, `--baseline`) |
|
||||
| `npm run check` | lint + typecheck + test + build in Folge |
|
||||
|
||||
## Sicherheitsprinzipien
|
||||
@@ -115,23 +118,24 @@ selbst spricht. Ein Docker-Abbild ist damit umgebungsneutral: einmal gebaut,
|
||||
- Fehlt `CRON_SECRET` oder stimmt der Header nicht, antwortet die Route mit
|
||||
`401` (nicht `500` — bewusst, siehe `tests/unit/security.test.ts`).
|
||||
|
||||
## Supabase-Hinweise
|
||||
## Datenbank
|
||||
|
||||
- Schema-Quelle der Wahrheit: `supabase/migrations/`. Menschlich lesbare
|
||||
Fassung, aus der laufenden Datenbank erzeugt:
|
||||
- Schema-Quelle der Wahrheit: `db/migrations/`. Menschlich lesbare Fassung,
|
||||
aus der laufenden Datenbank erzeugt:
|
||||
[`docs/datenkatalog.md`](docs/datenkatalog.md).
|
||||
- Migrationen einspielen: `supabase db push` (gegen das verlinkte Projekt)
|
||||
bzw. `supabase start` + automatische Anwendung für lokale Entwicklung.
|
||||
- `supabase/seed.ts` und `.env.test.local` sind nur für lokale
|
||||
Entwicklung/Tests gedacht, nie für ein Produktivprojekt verwenden.
|
||||
- Migrationen einspielen: `npm run migrate`. Der Läufer wendet nur die
|
||||
fehlenden Dateien an, jede in ihrer eigenen Transaktion, und führt darüber
|
||||
Buch in `migrationen.schema_migrations`.
|
||||
- `lib/types.ts` wird von Hand gepflegt. `npm run types:check` hält sie
|
||||
Spalte für Spalte gegen die Migrationen.
|
||||
|
||||
## Testing
|
||||
|
||||
- `npm run test` — schnell, keine externen Abhängigkeiten, läuft in CI.
|
||||
- `npm run test:integration` — braucht eine laufende lokale Supabase-Instanz
|
||||
(`supabase start`) und `.env.test.local`; prüft RLS-Verhalten end-to-end
|
||||
(siehe `tests/integration/authorization.test.ts` für das HR-Only-Zugriffs-
|
||||
modell).
|
||||
- `npm run test:integration` — braucht eine erreichbare Datenbank
|
||||
(`DATABASE_URL`). Geprüft werden Regeln, die es zweimal gibt: einmal als
|
||||
SQL, einmal als TypeScript. Ohne `DATABASE_URL` überspringen sich die
|
||||
Dateien, statt mit einem Verbindungsfehler abzubrechen.
|
||||
- `npm run test:e2e` — Playwright gegen einen laufenden Dev-/Preview-Server.
|
||||
|
||||
## Deployment
|
||||
@@ -141,15 +145,18 @@ Reverse-Proxy/TLS, der nächtliche Lauf, Migrationen und Updates.
|
||||
|
||||
## Known TODOs vor Produktivbetrieb
|
||||
|
||||
- **Content-Security-Policy fehlt noch** (`next.config.ts` setzt bewusst
|
||||
keine CSP — Skript-/Style-/Connect-Quellen sind noch nicht vollständig
|
||||
inventarisiert; ungeprüft geraten zu setzen riskiert, Hydration oder den
|
||||
Supabase-Client stillschweigend zu brechen).
|
||||
- **Lokale Scratch-Artefakte** (`.scratch_*`, `.scratch_shots/`) enthalten
|
||||
Screenshots/Hilfsskripte aus einer früheren manuellen Verifikation und
|
||||
liegen noch im Arbeitsverzeichnis. Sie sind jetzt über `.gitignore`
|
||||
ausgeschlossen; vor einem Produktiv-Handover sollten sie durchgesehen und
|
||||
bei Bedarf gelöscht werden.
|
||||
- **Content-Security-Policy läuft im Nur-Bericht-Modus** (`next.config.ts`).
|
||||
Erzwungen wird sie erst, wenn die Meldungen sauber sind — eine geratene,
|
||||
erzwungene Richtlinie blendet die Anwendung für alle aus.
|
||||
- **Seed für die Integrationstests fehlt.** Er lag in der abgelösten
|
||||
Umgebung. Zwei der drei Integrationstests vergleichen Regeln über den
|
||||
gesamten Bestand und brauchen dafür Daten; bis der Seed nachgezogen ist,
|
||||
laufen sie nur gegen eine bereits befüllte Datenbank, nicht in der CI.
|
||||
- **Sicherheitsprüfung des heutigen Aufbaus steht aus** — siehe
|
||||
[`docs/security-review.md`](docs/security-review.md).
|
||||
- **Bildschirmfotos unter `.scratch_shots/`** stammen aus einer früheren
|
||||
Handprüfung. Sie sind über `.gitignore` ausgeschlossen; vor der Übergabe
|
||||
durchsehen und löschen.
|
||||
- **Kein granulareres Rollenmodell** — aktuell HR-only (alles-oder-nichts).
|
||||
Falls z. B. eine reine Lese-Rolle künftig gebraucht wird, gehört die
|
||||
Erweiterung in eine neue Migration (`is_hr_user()`/RLS-Policies), nicht in
|
||||
|
||||
Reference in New Issue
Block a user