fix: make exercise goal and execution optional (at least one required)
Error: 224/225 exercises failed with NOT NULL constraint violations
Root cause: exercises table requires BOTH goal AND execution (NOT NULL)
Reality: Many wiki exercises have only ONE of these fields
Migration 019:
- ALTER COLUMN goal DROP NOT NULL
- ALTER COLUMN execution DROP NOT NULL
- ADD CHECK constraint: (goal IS NOT NULL OR execution IS NOT NULL)
This allows:
✓ Exercises with only goal
✓ Exercises with only execution
✓ Exercises with both
✗ Exercises with neither (CHECK constraint fails)
Import validation already correct (line 312):
required_ok = bool(mapped.get('goal') or mapped.get('execution'))
DB schema was blocking valid exercises.
This commit is contained in:
parent
a37400bb22
commit
bcc7d61d07
11
backend/migrations/019_exercises_optional_fields.sql
Normal file
11
backend/migrations/019_exercises_optional_fields.sql
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
-- Migration 019: Make exercise goal and execution optional
|
||||
-- Many wiki exercises have only goal OR execution, not both
|
||||
|
||||
ALTER TABLE exercises
|
||||
ALTER COLUMN goal DROP NOT NULL,
|
||||
ALTER COLUMN execution DROP NOT NULL;
|
||||
|
||||
-- Add CHECK constraint: at least one of goal/execution must be present
|
||||
ALTER TABLE exercises
|
||||
ADD CONSTRAINT exercises_goal_or_execution_required
|
||||
CHECK (goal IS NOT NULL OR execution IS NOT NULL);
|
||||
Loading…
Reference in New Issue
Block a user