From 553d7d1780a7635a81f0fcc80e3a4c0e5301e679 Mon Sep 17 00:00:00 2001 From: Jet Date: Wed, 18 Mar 2026 17:52:33 -0700 Subject: [PATCH] fix: update schema for no migration, only nukes --- remote/cache-service/src/db.rs | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/remote/cache-service/src/db.rs b/remote/cache-service/src/db.rs index 0831cf8..b9b3579 100644 --- a/remote/cache-service/src/db.rs +++ b/remote/cache-service/src/db.rs @@ -10,7 +10,7 @@ pub fn init(path: &str) -> Result { " CREATE TABLE IF NOT EXISTS current_state ( id INTEGER PRIMARY KEY CHECK (id = 1), - status TEXT, + status TEXT NOT NULL DEFAULT 'offline', timestamp INTEGER, last_seen INTEGER, last_checked INTEGER @@ -29,23 +29,11 @@ pub fn init(path: &str) -> Result { fetched_at INTEGER NOT NULL ); - INSERT OR IGNORE INTO current_state (id, status, timestamp, last_seen, last_checked) VALUES (1, 'offline', NULL, NULL, NULL); + INSERT OR IGNORE INTO current_state (id) VALUES (1); INSERT OR IGNORE INTO pi_info (id, data, fetched_at) VALUES (1, '{}', 0); ", ) .context("failed to initialize database schema")?; - - // Migration: add last_checked column if missing (existing databases) - let has_last_checked: bool = conn - .prepare("SELECT last_checked FROM current_state LIMIT 1") - .is_ok(); - if !has_last_checked { - conn.execute_batch("ALTER TABLE current_state ADD COLUMN last_checked INTEGER")?; - } - - // Migration: convert NULL status to 'offline' - conn.execute("UPDATE current_state SET status = 'offline' WHERE status IS NULL", [])?; - Ok(conn) }