From 59cec63da116f785619b302e03e29193d752ca2d Mon Sep 17 00:00:00 2001 From: kami Date: Fri, 31 Jul 2026 14:30:54 +0400 Subject: [PATCH] List the columns in the table rebuild The migration copied rows with SELECT *, which matches columns by position. It is correct today, but if the old table's order ever differed it would shuffle every row instead of failing. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01CGeSZxh1DCtRxmFVSYVGvJ --- internal/store/migrations.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/internal/store/migrations.go b/internal/store/migrations.go index e67bd43..8bc86eb 100644 --- a/internal/store/migrations.go +++ b/internal/store/migrations.go @@ -91,7 +91,9 @@ ALTER TABLE reminders ADD COLUMN next_fire_ts INTEGER;`, // #2 // #12 — a suppressed nudge gets a 'dropped' row (Vikunja #370). sqlite // can't widen a CHECK constraint in place, so the table is rebuilt; the - // index goes with the old table and is recreated. + // index goes with the old table and is recreated. The columns are listed + // out rather than `SELECT *` — copying by position would silently shuffle + // every row if the old table's column order ever differed from this one. `CREATE TABLE delivery_attempts_v12 ( id INTEGER PRIMARY KEY AUTOINCREMENT, kind TEXT NOT NULL CHECK (kind IN ('nudge','reminder')), @@ -103,7 +105,10 @@ ALTER TABLE reminders ADD COLUMN next_fire_ts INTEGER;`, // #2 created_ts INTEGER NOT NULL, completed_ts INTEGER ); - INSERT INTO delivery_attempts_v12 SELECT * FROM delivery_attempts; + INSERT INTO delivery_attempts_v12 + (id, kind, rule, reminder_id, channel, body_hash, status, created_ts, completed_ts) + SELECT id, kind, rule, reminder_id, channel, body_hash, status, created_ts, completed_ts + FROM delivery_attempts; DROP TABLE delivery_attempts; ALTER TABLE delivery_attempts_v12 RENAME TO delivery_attempts; CREATE INDEX IF NOT EXISTS idx_delivery_attempts_status ON delivery_attempts (status);`,