Update README and moderation commands for localization and migration support
- Revised README to include database migration steps and a new section for database management. - Enhanced moderation command responses to utilize localized messages for unknown commands. - Refactored moderation commands to use centralized command data definitions, improving maintainability and consistency. - Added localization support for command descriptions and options in both German and English. - Versioned Prisma migrations for better tracking of database changes.
This commit is contained in:
101
docs/DATABASE.md
Normal file
101
docs/DATABASE.md
Normal file
@@ -0,0 +1,101 @@
|
||||
# Nexumi – Datenbank
|
||||
|
||||
## Migrationen
|
||||
|
||||
Prisma-Schema: `apps/bot/prisma/schema.prisma`
|
||||
|
||||
Initiale Migration:
|
||||
|
||||
- `apps/bot/prisma/migrations/20260722123000_init`
|
||||
|
||||
### Lokale Entwicklung
|
||||
|
||||
1. Stack starten:
|
||||
|
||||
```bash
|
||||
docker compose up -d postgres redis
|
||||
```
|
||||
|
||||
2. `.env` setzen (Beispiel lokal):
|
||||
|
||||
```env
|
||||
DATABASE_URL=postgresql://nexumi:nexumi@localhost:5432/nexumi
|
||||
```
|
||||
|
||||
Hinweis: Im Compose-Stack ist Postgres absichtlich nicht nach außen veröffentlicht. Für lokale Migrationen außerhalb von Docker entweder temporär einen Port mappen oder Migrationen im Bot-Container ausführen.
|
||||
|
||||
3. Migration anwenden:
|
||||
|
||||
```bash
|
||||
pnpm prisma:migrate
|
||||
```
|
||||
|
||||
Alternativ im Bot-Container:
|
||||
|
||||
```bash
|
||||
docker compose run --rm bot pnpm prisma:migrate
|
||||
```
|
||||
|
||||
4. Client generieren:
|
||||
|
||||
```bash
|
||||
pnpm prisma:generate
|
||||
```
|
||||
|
||||
## Backup (automatisch)
|
||||
|
||||
- Job: BullMQ `dailyPgDump`
|
||||
- Cron: `BACKUP_CRON` (Default `0 3 * * *`)
|
||||
- Zielverzeichnis: `BACKUP_DIR` (Default `/backups`)
|
||||
- Retention: `BACKUP_RETENTION_DAYS` (Default `14`)
|
||||
|
||||
Backups liegen im Docker-Volume `backups`, am Bot-Container unter `/backups`.
|
||||
|
||||
### Manuelles Backup
|
||||
|
||||
```bash
|
||||
docker compose exec bot sh -c "pg_dump --dbname \"$DATABASE_URL\" --file /backups/manual-$(date -u +%Y%m%dT%H%M%SZ).sql"
|
||||
```
|
||||
|
||||
## Restore
|
||||
|
||||
1. Bot/WebUI stoppen:
|
||||
|
||||
```bash
|
||||
docker compose stop bot webui
|
||||
```
|
||||
|
||||
2. Backup-Datei in den Postgres-Container kopieren (Beispiel):
|
||||
|
||||
```bash
|
||||
docker compose cp ./backups/nexumi-2026-07-22.sql postgres:/tmp/restore.sql
|
||||
```
|
||||
|
||||
3. Restore ausführen:
|
||||
|
||||
```bash
|
||||
docker compose exec -T postgres psql -U nexumi -d nexumi -f /tmp/restore.sql
|
||||
```
|
||||
|
||||
4. Services wieder starten:
|
||||
|
||||
```bash
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
## Audit-Metadaten (Cases)
|
||||
|
||||
Standardisierte Case-Metadaten werden zentral über `buildCaseMetadata()` in `@nexumi/shared` erzeugt.
|
||||
|
||||
Pflichtfelder:
|
||||
|
||||
- `source` (`slash_command`, `button_confirmation`, `escalation`, `job`)
|
||||
- `recordedAt` (ISO-Zeitstempel)
|
||||
|
||||
Optionale Felder je nach Aktion:
|
||||
|
||||
- `channelId`
|
||||
- `confirmed`
|
||||
- `escalation`, `warningCount`, `durationMs`
|
||||
- `purge.requestedAmount`, `purge.deletedCount`, `purge.filters`
|
||||
- `deletedCaseId`, `deletedCaseNumber`
|
||||
@@ -56,21 +56,18 @@ Dieses Dokument hält den aktuellen Implementierungsstand fest. Es wird bei jede
|
||||
- `/case view|edit|delete`
|
||||
- `/modnote add|list`
|
||||
- user-facing Reply-Strings im Moderationsfluss auf i18n-Keys umgestellt (`de`/`en`)
|
||||
- Slash-Command-Beschreibungen und Optionstexte lokalisiert (`de` + `en-US` via Discord-Localizations)
|
||||
- Bestätigungsflow für destruktive Aktionen (`/ban`, `/purge`, `/case delete`) mit Buttons
|
||||
- standardisierte Case-Audit-Metadaten über `@nexumi/shared` (`buildCaseMetadata`)
|
||||
- Prisma-Migrationen versioniert:
|
||||
- `apps/bot/prisma/migrations/20260722123000_init`
|
||||
- Tests (aktuell vorhanden):
|
||||
- `packages/shared/src/i18n.test.ts`
|
||||
- `packages/shared/src/audit.test.ts`
|
||||
- `apps/bot/src/modules/moderation/duration.test.ts`
|
||||
|
||||
### Noch offen für Phase 1
|
||||
|
||||
- Vollständige i18n-Auslagerung:
|
||||
- Restarbeiten: Command-Beschreibungen/-Optionstexte ebenfalls in zentralen Locale-Strukturen führen.
|
||||
- Audit-/Case-System weiter härten:
|
||||
- Einheitliche, nachvollziehbare Audit-Metadaten pro Moderationsaktion.
|
||||
- Migrations-Workflow finalisieren:
|
||||
- Neue Prisma-Migration für `EscalationRule` erzeugen und versionieren.
|
||||
- Setup-Doku erweitern:
|
||||
- Konkrete Restore-/Backup-Runbook-Schritte mit Beispielbefehlen pro Umgebung.
|
||||
- `docker compose up -d` End-to-End gegen echte `.env` und Test-Discord-Guild final verifizieren.
|
||||
|
||||
### Verifikation (letzter Lauf)
|
||||
|
||||
Reference in New Issue
Block a user