- 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.
2.0 KiB
2.0 KiB
Nexumi – Datenbank
Migrationen
Prisma-Schema: apps/bot/prisma/schema.prisma
Initiale Migration:
apps/bot/prisma/migrations/20260722123000_init
Lokale Entwicklung
- Stack starten:
docker compose up -d postgres redis
.envsetzen (Beispiel lokal):
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.
- Migration anwenden:
pnpm prisma:migrate
Alternativ im Bot-Container:
docker compose run --rm bot pnpm prisma:migrate
- Client generieren:
pnpm prisma:generate
Backup (automatisch)
- Job: BullMQ
dailyPgDump - Cron:
BACKUP_CRON(Default0 3 * * *) - Zielverzeichnis:
BACKUP_DIR(Default/backups) - Retention:
BACKUP_RETENTION_DAYS(Default14)
Backups liegen im Docker-Volume backups, am Bot-Container unter /backups.
Manuelles Backup
docker compose exec bot sh -c "pg_dump --dbname \"$DATABASE_URL\" --file /backups/manual-$(date -u +%Y%m%dT%H%M%SZ).sql"
Restore
- Bot/WebUI stoppen:
docker compose stop bot webui
- Backup-Datei in den Postgres-Container kopieren (Beispiel):
docker compose cp ./backups/nexumi-2026-07-22.sql postgres:/tmp/restore.sql
- Restore ausführen:
docker compose exec -T postgres psql -U nexumi -d nexumi -f /tmp/restore.sql
- Services wieder starten:
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:
channelIdconfirmedescalation,warningCount,durationMspurge.requestedAmount,purge.deletedCount,purge.filtersdeletedCaseId,deletedCaseNumber