From 902705f47f024cd0ef9b87b14b39e88d78f886aa Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Sun, 18 Jan 2026 15:42:11 -0600 Subject: [PATCH] fix(phase4): add icon_background column migration for existing databases - Detect missing icon_background column in favorites_preferences table - Add ALTER TABLE migration to preserve existing user data - Apply migration in both FavoritesPreferencesStore::new() and create_table() cx --- src-tauri/src/config/favorites_preferences.rs | 28 +++++++++++++++++-- src/lib/components/FavoritesEditModal.svelte | 1 - 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/config/favorites_preferences.rs b/src-tauri/src/config/favorites_preferences.rs index 372a9a8aa..5dc32e803 100644 --- a/src-tauri/src/config/favorites_preferences.rs +++ b/src-tauri/src/config/favorites_preferences.rs @@ -48,13 +48,25 @@ impl FavoritesPreferencesStore { id INTEGER PRIMARY KEY CHECK (id = 1), custom_icon_path TEXT, custom_icon_preset TEXT, - icon_background TEXT, tab_order TEXT NOT NULL )", [], ) .map_err(|e| format!("Failed to create favorites preferences table: {}", e))?; + // Migration: Add icon_background column if it doesn't exist + let has_icon_background = conn + .prepare("SELECT icon_background FROM favorites_preferences LIMIT 1") + .is_ok(); + + if !has_icon_background { + conn.execute( + "ALTER TABLE favorites_preferences ADD COLUMN icon_background TEXT", + [], + ) + .map_err(|e| format!("Failed to add icon_background column: {}", e))?; + } + Ok(Self { conn }) } @@ -148,11 +160,23 @@ pub fn create_table(conn: &Connection) -> Result<()> { id INTEGER PRIMARY KEY CHECK (id = 1), custom_icon_path TEXT, custom_icon_preset TEXT, - icon_background TEXT, tab_order TEXT NOT NULL )", [], )?; + + // Migration: Add icon_background column if it doesn't exist + let has_icon_background = conn + .prepare("SELECT icon_background FROM favorites_preferences LIMIT 1") + .is_ok(); + + if !has_icon_background { + conn.execute( + "ALTER TABLE favorites_preferences ADD COLUMN icon_background TEXT", + [], + )?; + } + Ok(()) } diff --git a/src/lib/components/FavoritesEditModal.svelte b/src/lib/components/FavoritesEditModal.svelte index 85fe08aa5..d4c4c13db 100644 --- a/src/lib/components/FavoritesEditModal.svelte +++ b/src/lib/components/FavoritesEditModal.svelte @@ -555,7 +555,6 @@ justify-content: flex-end; gap: 12px; padding-top: 24px; - border-top: 1px solid var(--bg-tertiary); } .btn {