Problem: User can create multiple rest days of same type per date (e.g., 2x Mental Rest on 2026-03-23) - makes no sense. Solution: UNIQUE constraint on (profile_id, date, focus) ## Migration 012: - Add focus column (extracted from rest_config JSONB) - Populate from existing data - Add NOT NULL constraint - Add CHECK constraint (valid focus values) - Add UNIQUE constraint (profile_id, date, focus) - Add index for performance ## Backend: - Insert focus column alongside rest_config - Handle UniqueViolation gracefully - User-friendly error: "Du hast bereits einen Ruhetag 'Muskelregeneration' für 23.03." ## Benefits: - DB-level enforcement (clean) - Fast queries (no JSONB scan) - Clear error messages - Prevents: 2x muscle_recovery same day - Allows: muscle_recovery + mental_rest same day ✓ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| migrations | ||
| routers | ||
| apply_v9c_migration.py | ||
| auth.py | ||
| check_features.py | ||
| db_init.py | ||
| db.py | ||
| Dockerfile | ||
| feature_logger.py | ||
| main_old.py | ||
| main.py | ||
| migrate_to_postgres.py | ||
| models.py | ||
| requirements.txt | ||
| schema.sql | ||
| startup.sh | ||