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
This commit is contained in:
1 parent
ad73b5d879
commit
902705f47f
2 files changed
+26
-3
No files matched your search
@@ -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(())
|
||||
}
|
||||
|
||||
|
||||
@@ -555,7 +555,6 @@
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
padding-top: 24px;
|
||||
border-top: 1px solid var(--bg-tertiary);
|
||||
}
|
||||
|
||||
.btn {
|
||||
|
||||
Reference in new issue
Block a user