fix(journey): make the source_assignment_id migration replay-safe

An unreleased migration has to survive being replayed on a schema where it
already applied — installs skip releases, and a test rewinds a fully migrated
database to the last released version to prove it. The bare ADD COLUMN threw
"duplicate column name" on that replay, which took every migration test down
with it.

Guard the ALTER on pragma_table_info, and add `source_assignment_id IS NULL`
to the backfill so a replay cannot re-resolve a row that has since followed
its stop to another day.

The trips e2e harness hand-builds a minimal journey_entries table rather than
running migrations, so it needs the column spelled out too.
This commit is contained in:
Konstantinos Thermos
2026-09-16 16:32:02 +03:00
parent 4eaf90fd1b
commit 5f57c63426
2 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ const { db } = vi.hoisted(() => {
created_at DATETIME DEFAULT CURRENT_TIMESTAMP);`);
// deleteTrip cleans up synced journey entries before dropping the trip row.
tmp.exec(`CREATE TABLE journey_entries (id INTEGER PRIMARY KEY AUTOINCREMENT, journey_id INTEGER,
source_trip_id INTEGER, source_place_id INTEGER, type TEXT NOT NULL);`);
source_trip_id INTEGER, source_place_id INTEGER, source_assignment_id INTEGER, type TEXT NOT NULL);`);
// bundle()'s todoItems now runs TodoService's real SQL (DI-injected, no mock).
tmp.exec(`CREATE TABLE todo_items (id INTEGER PRIMARY KEY AUTOINCREMENT, trip_id INTEGER NOT NULL,
name TEXT NOT NULL, checked INTEGER NOT NULL DEFAULT 0, category TEXT, sort_order INTEGER NOT NULL DEFAULT 0,