{"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":1572,"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":1554,"sourceCodeEnd":1590,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/sqlite/SessionStore.ts#L1554-L1590","documentation":"SessionStore performs idempotent schema migrations that rename legacy columns in sdk_sessions (claude_session_id→content_session_id, sdk_session_id→memory_session_id). safeRenameColumn checks column existence first; when the old column is absent the rename is skipped with this warning and returns false (so renamesPerformed is not incremented). This is expected on fresh databases or already-migrated schemas — not an error.","triggerScenarios":"SessionStore migration runs safeRenameColumn for a table where PRAGMA/table-info shows the old column does not exist — fresh DB created directly with the new schema, or the rename was already applied in a prior run.","commonSituations":"First run after upgrading where the migration already completed on another start; brand-new database that never had the legacy columns; restoring a DB backup from a newer schema.","solutions":["No action needed — the migration is idempotent and the warning confirms the rename was unnecessary","If you expected the old columns to exist, verify the database file being opened is the right one (~/.claude-mem/claude-mem.db) and not a freshly created one","Check prior migration logs (renamesPerformed counter) to confirm the rename already happened"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"const cols = db.prepare(`PRAGMA table_info(sdk_sessions)`).all().map(c => c.name);\nconst needsRename = cols.includes('claude_session_id');","typeGuard":"function hasColumn(db: Database, table: string, col: string): boolean {\n  return db.prepare(`PRAGMA table_info(${table})`).all()\n    .some((c: { name: string }) => c.name === col);\n}","tryCatchPattern":"if (hasColumn(db, 'sdk_sessions', 'claude_session_id')) {\n  db.run(`ALTER TABLE sdk_sessions RENAME COLUMN claude_session_id TO content_session_id`);\n} // else: skip silently — already migrated","preventionTips":["Treat this warning as expected on fresh/already-migrated schemas","Confirm you are opening the intended database file before judging migration state","Make migrations idempotent with existence checks before ALTER TABLE","Track renamesPerformed counters in logs to verify migration progress"],"tags":["database","migration","sqlite","schema"],"backgroundTag":"deprecated-api-usage","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}