{"record":{"id":"88b3cb6f2d101229","repo":"diegosouzapw/OmniRoute","slug":"db-failed-to-verify-usage-history-schema","errorCode":null,"errorMessage":"[DB] Failed to verify usage_history schema:","messagePattern":"\\[DB\\] Failed to verify usage_history schema:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/db/schemaColumns.ts","lineNumber":162,"sourceCode":"      console.log(\"[DB] Added usage_history.account_label_priority column\");\n    }\n    db.exec(\n      \"CREATE INDEX IF NOT EXISTS idx_uh_provider_model_timestamp ON usage_history(provider, model, timestamp)\"\n    );\n    db.exec(\n      `CREATE INDEX IF NOT EXISTS idx_uh_dedup ON usage_history(\n        timestamp,\n        COALESCE(provider, ''),\n        COALESCE(model, ''),\n        COALESCE(connection_id, ''),\n        COALESCE(api_key_id, ''),\n        tokens_input,\n        tokens_output\n      )`\n    );\n  } catch (error: unknown) {\n    const message = error instanceof Error ? error.message : String(error);\n    console.warn(\"[DB] Failed to verify usage_history schema:\", message);\n  }\n}\n\nexport function ensureCallLogsColumns(db: SqliteDatabase) {\n  try {\n    const columns = db.prepare(\"PRAGMA table_info(call_logs)\").all() as Array<{\n      name?: string;\n    }>;\n    const columnNames = new Set(columns.map((column) => String(column.name ?? \"\")));\n\n    if (!columnNames.has(\"artifact_relpath\")) {\n      db.exec(\"ALTER TABLE call_logs ADD COLUMN artifact_relpath TEXT\");\n      console.log(\"[DB] Added call_logs.artifact_relpath column\");\n    }\n    if (!columnNames.has(\"has_pipeline_details\")) {\n      db.exec(\"ALTER TABLE call_logs ADD COLUMN has_pipeline_details INTEGER DEFAULT 0\");\n      console.log(\"[DB] Added call_logs.has_pipeline_details column\");\n    }","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/db/schemaColumns.ts#L144-L180","documentation":"Error \"[DB] Failed to verify usage_history schema:\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/db/schemaColumns.ts:162 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"}