42 lines
1.3 KiB
Markdown
42 lines
1.3 KiB
Markdown
---
|
|
id: DIS-108
|
|
status: backlog
|
|
phase: 1
|
|
priority: p1
|
|
labels: [phase:1, type:refactor, priority:p1]
|
|
branch: phase-1/db-schema-ssot
|
|
assignee: null
|
|
started: null
|
|
pr: null
|
|
merged: null
|
|
---
|
|
|
|
# DIS-108: DB-Schema SSOT → `src/db/schema.sql`
|
|
|
|
## Ziel
|
|
Das SQLite-Schema ist in einer einzigen `schema.sql`-Datei definiert (Single Source of Truth).
|
|
`database.ts` liest und führt die Datei aus statt SQL inline zu haben.
|
|
|
|
## Kontext
|
|
→ `docs/development-plan.md` §2 (DB-Architektur), Phase 1 Task 8.
|
|
|
|
## Scope
|
|
- **In**: `src/db/schema.sql` mit allen `CREATE TABLE`-Statements (inkl. `conversations`-Index) · `database.ts` liest Schema via `fs.readFileSync` und wendet es über `db.run()` auf die SQLite-Instanz an · Bestehende Inline-SQL entfernen
|
|
- **Out**: DB-Migrations-System (kommt mit Phase 2 `session_id`-Spalte als erstes Delta)
|
|
|
|
## Definition of Done
|
|
- [ ] `schema.sql` enthält alle Tabellen und Indizes
|
|
- [ ] `database.ts` hat kein Inline-DDL mehr
|
|
- [ ] Integration-Test `tests/integration/db-init.test.ts` mit tmp-SQLite verifiziert: Tabellen existieren, Indizes greifen, zweites Ausführen ist idempotent
|
|
- [ ] `npm run build && npm test` grün
|
|
|
|
## Dateien (erwartet)
|
|
- `src/db/schema.sql`
|
|
- `src/db/database.ts`
|
|
- `tests/integration/db-init.test.ts`
|
|
|
|
## Abhängigkeiten
|
|
Blockiert durch: **DIS-101**.
|
|
|
|
## Spec
|
|
→ `docs/backlog.md` #DIS-108
|