From 992619b23e9bc1b60805b9c36b4d84a22538fdb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Tue, 14 Jul 2026 04:35:02 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(db)!:=20drop=20backfills=20t?= =?UTF-8?q?hat=20crashed=20boot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Single-field backfills fail on volumes predating the attempt/rejoin fields: UPDATE re-validates the whole record, so backfilling max_attempts tripped bool coercion on the still-NONE allow_rejoin before its own backfill could run. DEFAULT only applies on CREATE, so it never rescues existing records. Pre-customer policy is clean breaks over migrations: remove the exam and exam_attempt backfills plus the old-index compat drop instead of merging them into one statement. BREAKING CHANGE: volumes created before the attempt/rejoin fields no longer boot; wipe the data volume (podman volume rm hezarfen_backend_hezarfen-data) and reseed. --- src/database.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/database.rs b/src/database.rs index 42fe7be..009af27 100644 --- a/src/database.rs +++ b/src/database.rs @@ -128,8 +128,6 @@ const MIGRATION: &str = " DEFINE FIELD IF NOT EXISTS max_attempts ON exam TYPE int DEFAULT 1; DEFINE FIELD IF NOT EXISTS allow_rejoin ON exam TYPE bool DEFAULT true; DEFINE INDEX IF NOT EXISTS exam_course ON exam FIELDS course; - UPDATE exam SET max_attempts = 1 WHERE max_attempts = NONE; - UPDATE exam SET allow_rejoin = true WHERE allow_rejoin = NONE; DEFINE TABLE IF NOT EXISTS exam_attempt SCHEMAFULL; DEFINE FIELD IF NOT EXISTS exam ON exam_attempt TYPE record; @@ -138,8 +136,6 @@ const MIGRATION: &str = " DEFINE FIELD IF NOT EXISTS started_at ON exam_attempt TYPE int; DEFINE FIELD IF NOT EXISTS finished_at ON exam_attempt TYPE option; DEFINE FIELD IF NOT EXISTS left_at ON exam_attempt TYPE option; - UPDATE exam_attempt SET seq = 1 WHERE seq = NONE; - REMOVE INDEX IF EXISTS exam_attempt_exam_user ON TABLE exam_attempt; DEFINE INDEX IF NOT EXISTS exam_attempt_exam_user_seq ON exam_attempt FIELDS exam, user, seq UNIQUE; DEFINE INDEX IF NOT EXISTS exam_attempt_exam ON exam_attempt FIELDS exam;