From bcc7d61d07c518920a3e204c67ae70ef83c50c11 Mon Sep 17 00:00:00 2001 From: Lars Date: Fri, 24 Apr 2026 20:42:21 +0200 Subject: [PATCH] fix: make exercise goal and execution optional (at least one required) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- backend/migrations/019_exercises_optional_fields.sql | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 backend/migrations/019_exercises_optional_fields.sql diff --git a/backend/migrations/019_exercises_optional_fields.sql b/backend/migrations/019_exercises_optional_fields.sql new file mode 100644 index 0000000..b8ccb62 --- /dev/null +++ b/backend/migrations/019_exercises_optional_fields.sql @@ -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);