{"record":{"id":"6432e58eeb8cb880","repo":"diegosouzapw/OmniRoute","slug":"db-failed-to-verify-provider-connections-schema","errorCode":null,"errorMessage":"[DB] Failed to verify provider_connections schema:","messagePattern":"\\[DB\\] Failed to verify provider_connections schema:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/db/schemaColumns.ts","lineNumber":88,"sourceCode":"    // `refresh_token` is part of 001_initial_schema.sql, but `CREATE TABLE IF NOT EXISTS`\n    // is a no-op on a pre-existing legacy table that predates it — heal it defensively\n    // before the index below relies on it, or a very old DB fails startup entirely.\n    if (!columnNames.has(\"refresh_token\")) {\n      db.exec(\"ALTER TABLE provider_connections ADD COLUMN refresh_token TEXT\");\n      console.log(\"[DB] Added provider_connections.refresh_token column\");\n    }\n    db.exec(\n      \"CREATE INDEX IF NOT EXISTS idx_pc_max_concurrent ON provider_connections(provider, max_concurrent)\"\n    );\n    db.exec(\n      \"CREATE INDEX IF NOT EXISTS idx_pc_auth_active_refresh ON provider_connections(auth_type, is_active, refresh_token)\"\n    );\n    db.exec(\n      \"CREATE INDEX IF NOT EXISTS idx_pc_provider_auth_type ON provider_connections(provider, auth_type)\"\n    );\n  } catch (error: unknown) {\n    const message = error instanceof Error ? error.message : String(error);\n    console.warn(\"[DB] Failed to verify provider_connections schema:\", message);\n  }\n}\n\nexport function ensureUsageHistoryAccountIndex(db: SqliteDatabase) {\n  try {\n    db.exec(\"CREATE INDEX IF NOT EXISTS idx_uh_account_key ON usage_history(account_key)\");\n  } catch (error: unknown) {\n    const message = error instanceof Error ? error.message : String(error);\n    console.warn(\"[DB] Failed to verify usage_history account index:\", message);\n  }\n}\n\nexport function ensureUsageHistoryColumns(db: SqliteDatabase) {\n  try {\n    const columns = db.prepare(\"PRAGMA table_info(usage_history)\").all() as Array<{\n      name?: string;\n    }>;\n    const columnNames = new Set(columns.map((column) => String(column.name ?? \"\")));","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/db/schemaColumns.ts#L70-L106","documentation":"Error \"[DB] Failed to verify provider_connections schema:\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/db/schemaColumns.ts:88 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}