forge
Explore
Log in

Don't you dare go Hollow

Drop backfills that crashed boot

Browse files at this commit

992619b23e9bc1b60805b9c36b4d84a22538fdb7Ahmet Kaan GümüşParent: 3681441
  • fix
    • drop backfills that crashed boot
Show full message
🐛 fix(db)!: drop backfills that crashed boot

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.rsmodified+0 -4
@@ -128,8 +128,6 @@ const MIGRATION: &str = "
128 DEFINE FIELD IF NOT EXISTS max_attempts ON exam TYPE int DEFAULT 1;128 DEFINE FIELD IF NOT EXISTS max_attempts ON exam TYPE int DEFAULT 1;
129 DEFINE FIELD IF NOT EXISTS allow_rejoin ON exam TYPE bool DEFAULT true;129 DEFINE FIELD IF NOT EXISTS allow_rejoin ON exam TYPE bool DEFAULT true;
130 DEFINE INDEX IF NOT EXISTS exam_course ON exam FIELDS course;130 DEFINE INDEX IF NOT EXISTS exam_course ON exam FIELDS course;
131- UPDATE exam SET max_attempts = 1 WHERE max_attempts = NONE;
132- UPDATE exam SET allow_rejoin = true WHERE allow_rejoin = NONE;
133 131
134 DEFINE TABLE IF NOT EXISTS exam_attempt SCHEMAFULL;132 DEFINE TABLE IF NOT EXISTS exam_attempt SCHEMAFULL;
135 DEFINE FIELD IF NOT EXISTS exam ON exam_attempt TYPE record<exam>;133 DEFINE FIELD IF NOT EXISTS exam ON exam_attempt TYPE record<exam>;
@@ -138,8 +136,6 @@ const MIGRATION: &str = "
138 DEFINE FIELD IF NOT EXISTS started_at ON exam_attempt TYPE int;136 DEFINE FIELD IF NOT EXISTS started_at ON exam_attempt TYPE int;
139 DEFINE FIELD IF NOT EXISTS finished_at ON exam_attempt TYPE option<int>;137 DEFINE FIELD IF NOT EXISTS finished_at ON exam_attempt TYPE option<int>;
140 DEFINE FIELD IF NOT EXISTS left_at ON exam_attempt TYPE option<int>;138 DEFINE FIELD IF NOT EXISTS left_at ON exam_attempt TYPE option<int>;
141- UPDATE exam_attempt SET seq = 1 WHERE seq = NONE;
142- REMOVE INDEX IF EXISTS exam_attempt_exam_user ON TABLE exam_attempt;
143 DEFINE INDEX IF NOT EXISTS exam_attempt_exam_user_seq ON exam_attempt FIELDS exam, user, seq UNIQUE;139 DEFINE INDEX IF NOT EXISTS exam_attempt_exam_user_seq ON exam_attempt FIELDS exam, user, seq UNIQUE;
144 DEFINE INDEX IF NOT EXISTS exam_attempt_exam ON exam_attempt FIELDS exam;140 DEFINE INDEX IF NOT EXISTS exam_attempt_exam ON exam_attempt FIELDS exam;
145 141