From 9839ebe4deaa58fa2a3924817b353286c61b0a0b Mon Sep 17 00:00:00 2001 From: Ruben Rosario Date: Sun, 21 Jun 2026 16:09:05 +0100 Subject: [PATCH] Fix ALTER TABLE migration for created_at column SQLite ALTER TABLE ADD COLUMN does not support DEFAULT expressions, only literal values. Use DEFAULT '' then UPDATE existing rows. --- src/infrastructure/db.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/db.rs b/src/infrastructure/db.rs index 745283d..6c4ab7c 100644 --- a/src/infrastructure/db.rs +++ b/src/infrastructure/db.rs @@ -47,7 +47,11 @@ impl Db { ) .ok(); conn.execute_batch( - "ALTER TABLE tasks ADD COLUMN created_at TEXT NOT NULL DEFAULT (strftime('%Y-%m-%d %H:%M:%S', 'now'));", + "ALTER TABLE tasks ADD COLUMN created_at TEXT NOT NULL DEFAULT '';", + ) + .ok(); + conn.execute_batch( + "UPDATE tasks SET created_at = updated_at WHERE created_at = '';", ) .ok(); Ok(Self { conn: Mutex::new(conn) })