diff --git a/services/database.ts b/services/database.ts index e46cd65..a816734 100644 --- a/services/database.ts +++ b/services/database.ts @@ -141,16 +141,6 @@ function initializeDatabase(): Database { // Initialize settings table with default values initializeSettings(db); - // ALTER - // ALTER TABLE feeds ADD COLUMN category TEXT DEFAULT NULL; - // Ensure the category column exists in feeds - const feedInfos = db.prepare("PRAGMA table_info(feeds);").all(); - const hasFeedCategory = feedInfos.some((col: any) => col.name === "category"); - - if (!hasFeedCategory) { - db.exec("ALTER TABLE feeds ADD COLUMN category TEXT DEFAULT NULL;"); - } - // Ensure the category column exists in episodes const episodeInfos = db.prepare("PRAGMA table_info(episodes);").all(); const hasEpisodeCategory = episodeInfos.some( @@ -1623,7 +1613,7 @@ export async function initializeSettings(database: Database): Promise { required: true, }, { - key: "OPENAI_API_ENDPOINT", + key: "OPENAI_API_ENDPOINT", value: null, isCredential: false, description: "OpenAI API Endpoint URL", @@ -1765,7 +1755,7 @@ export async function initializeSettings(database: Database): Promise { for (const setting of defaultSettings) { try { const stmt = database.prepare( - "INSERT OR IGNORE INTO settings (key, value, is_credential, description, default_value, required, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)" + "INSERT OR IGNORE INTO settings (key, value, is_credential, description, default_value, required, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)", ); stmt.run( setting.key, @@ -1774,7 +1764,7 @@ export async function initializeSettings(database: Database): Promise { setting.description, setting.defaultValue, setting.required ? 1 : 0, - now + now, ); } catch (error) { console.error(`Error initializing setting ${setting.key}:`, error); @@ -1823,11 +1813,14 @@ export async function getSetting(key: string): Promise { } } -export async function updateSetting(key: string, value: string): Promise { +export async function updateSetting( + key: string, + value: string, +): Promise { try { const now = new Date().toISOString(); const stmt = db.prepare( - "UPDATE settings SET value = ?, updated_at = ? WHERE key = ?" + "UPDATE settings SET value = ?, updated_at = ? WHERE key = ?", ); const result = stmt.run(value, now, key); return result.changes > 0;