{"record":{"id":"03410d5ce50bade1","repo":"thedotmack/claude-mem","slug":"column-oldcol-not-found-in-table-skipping-r","errorCode":null,"errorMessage":"Column ${oldCol} not found in ${table}, skipping rename","messagePattern":"Column (.+?) not found in (.+?), skipping rename","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/services/sqlite/SessionStore.ts","lineNumber":1426,"sourceCode":"\n    let renamesPerformed = 0;\n\n    const safeRenameColumn = (table: string, oldCol: string, newCol: string): boolean => {\n      const tableInfo = this.db.query(`PRAGMA table_info(${table})`).all() as TableColumnInfo[];\n      const hasOldCol = tableInfo.some(col => col.name === oldCol);\n      const hasNewCol = tableInfo.some(col => col.name === newCol);\n\n      if (hasNewCol) {\n        return false;\n      }\n\n      if (hasOldCol) {\n        this.db.run(`ALTER TABLE ${table} RENAME COLUMN ${oldCol} TO ${newCol}`);\n        logger.debug('DB', `Renamed ${table}.${oldCol} to ${newCol}`);\n        return true;\n      }\n\n      logger.warn('DB', `Column ${oldCol} not found in ${table}, skipping rename`);\n      return false;\n    };\n\n    if (safeRenameColumn('sdk_sessions', 'claude_session_id', 'content_session_id')) renamesPerformed++;\n    if (safeRenameColumn('sdk_sessions', 'sdk_session_id', 'memory_session_id')) renamesPerformed++;\n\n    if (safeRenameColumn('pending_messages', 'claude_session_id', 'content_session_id')) renamesPerformed++;\n\n    if (safeRenameColumn('observations', 'sdk_session_id', 'memory_session_id')) renamesPerformed++;\n\n    if (safeRenameColumn('session_summaries', 'sdk_session_id', 'memory_session_id')) renamesPerformed++;\n\n    if (safeRenameColumn('user_prompts', 'claude_session_id', 'content_session_id')) renamesPerformed++;\n\n    this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(17, new Date().toISOString());\n\n    if (renamesPerformed > 0) {\n      logger.debug('DB', `Successfully renamed ${renamesPerformed} session ID columns`);","sourceCodeStart":1408,"sourceCodeEnd":1444,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/8bc631a71a487424b866756e43a6efa4574cc66b/src/services/sqlite/SessionStore.ts#L1408-L1444","documentation":"During the column-rename migration, `safeRenameColumn(table, oldCol, newCol)` inspects PRAGMA table_info. If the new column already exists it silently skips; if the old column exists it renames; when neither exists it logs this warning and returns false. It flags a schema generation the migration does not recognize — usually benign.","triggerScenarios":"A table (sdk_sessions, pending_messages, observations, session_summaries) exists but contains neither the legacy column (e.g. claude_session_id) nor its replacement (content_session_id) — a schema older than the rename or one that never had the column.","commonSituations":"Databases created by very old versions, restored or partially-migrated data files, or schema drift from manual edits.","solutions":["Usually safe to ignore — there is nothing to rename for that schema generation.","If sessions fail to link, run `PRAGMA table_info(sdk_sessions)` and compare with the expected schema.","As a last resort on a non-critical machine, rebuild the local index (uninstall/reinstall)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function hasColumn(db: { prepare(sql: string): { all(): Array<{ name: string }> } }, table: string, column: string): boolean {\n  return db.prepare(`PRAGMA table_info(${table})`).all().some((c) => c.name === column);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Back up the SQLite store before major version upgrades.","Never hand-edit the schema of the store's database."],"tags":["sqlite","schema-migration","column-rename"],"backgroundTag":"schema-migration-column-missing","analyzedSha":"8bc631a71a487424b866756e43a6efa4574cc66b","analyzedAt":"2026-08-20T23:58:13.836Z","contentChangedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}