- Added new models for premium tier configurations and assignments, enabling feature limits for free and premium users. - Introduced GDPR deletion logging and commands for user data management. - Enhanced logging configuration with retention days for audit logs. - Updated bot commands and job processing to include new premium and GDPR functionalities. - Improved localization with new keys for premium features and GDPR commands in both English and German. - Added UI components for managing premium settings and logging retention in the WebUI.
112 lines
2.4 KiB
Markdown
112 lines
2.4 KiB
Markdown
# 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
|
||
```
|
||
|
||
## Premium & DSGVO
|
||
|
||
- `PremiumTierConfig` (FREE/PREMIUM Limits + Feature-Flags)
|
||
- `GuildPremiumAssignment` / `UserPremiumAssignment`
|
||
- `GdprDeletionLog` (Protokoll der `/gdpr delete`-Läufe)
|
||
- `GuildSettings.snipeEnabled` (Default `false`)
|
||
- `LoggingConfig.retentionDays` (Default `90`, `0` = unbegrenzt)
|
||
|
||
Migration: `20260722200000_premium_gdpr`
|
||
|
||
## 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`
|