{"record":{"id":"31ff43c9e2ff90af","repo":"thedotmack/claude-mem","slug":"failed-to-drop-worker-pid-column-from-pending-mess","errorCode":null,"errorMessage":"Failed to drop worker_pid column from pending_messages","messagePattern":"Failed to drop worker_pid column from pending_messages","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/services/sqlite/SessionStore.ts","lineNumber":198,"sourceCode":"    `).get(contentSessionId) as { id: number } | undefined;\n\n    return row?.id ?? null;\n  }\n\n  private dropWorkerPidColumn(): void {\n    const applied = this.db.prepare('SELECT version FROM schema_versions WHERE version = ?').get(32) as SchemaVersion | undefined;\n\n    const cols = this.db.query('PRAGMA table_info(pending_messages)').all() as TableColumnInfo[];\n    const hasColumn = cols.some(c => c.name === 'worker_pid');\n    if (applied && !hasColumn) return;\n\n    if (hasColumn) {\n      try {\n        this.db.run('DROP INDEX IF EXISTS idx_pending_messages_worker_pid');\n        this.db.run('ALTER TABLE pending_messages DROP COLUMN worker_pid');\n        logger.debug('DB', 'Dropped worker_pid column and its index from pending_messages');\n      } catch (error) {\n        logger.warn('DB', 'Failed to drop worker_pid column from pending_messages', {}, error instanceof Error ? error : new Error(String(error)));\n        return;\n      }\n    }\n\n    if (!applied) {\n      this.db.prepare('INSERT OR IGNORE INTO schema_versions (version, applied_at) VALUES (?, ?)').run(32, new Date().toISOString());\n    }\n  }\n\n  private ensureSDKSessionsPlatformContentIdentity(): void {\n    const applied = this.db.prepare('SELECT version FROM schema_versions WHERE version = ?').get(33) as SchemaVersion | undefined;\n    const hasGlobalContentUnique = this.hasUniqueIndexOnColumns('sdk_sessions', ['content_session_id']);\n    const hasCompositeUnique = this.hasUniqueIndexOnColumns('sdk_sessions', ['platform_source', 'content_session_id']);\n    const columns = this.db.query('PRAGMA table_info(sdk_sessions)').all() as TableColumnInfo[];\n    const hasPlatformSource = columns.some(col => col.name === 'platform_source');\n\n    if (applied && !hasGlobalContentUnique && hasCompositeUnique && hasPlatformSource) return;\n","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/8bc631a71a487424b866756e43a6efa4574cc66b/src/services/sqlite/SessionStore.ts#L180-L216","documentation":"Schema migration v32 drops INDEX idx_pending_messages_worker_pid and the worker_pid column from pending_messages. On failure it warns and returns without recording version 32 in schema_versions, so the migration is retried on the next startup. Data is untouched; only the dead column lingers.","triggerScenarios":"SQLite older than 3.35.0, which has no ALTER TABLE DROP COLUMN support; the DB locked or read-only when the migration runs; the column referenced by a trigger or view so SQLite refuses the drop.","commonSituations":"An old runtime bundling an ancient SQLite; a second worker holding the write lock at startup; a DB restored read-only from backup.","solutions":["Read the attached error — 'near DROP: syntax error' means SQLite is older than 3.35; upgrade the runtime/driver","Ensure exactly one worker migrates at a time and the DB is writable","Verify afterwards with PRAGMA table_info(pending_messages) that worker_pid is gone","If you cannot upgrade, ignore it: the retry is idempotent and the leftover column is harmless"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"const { v } = db.prepare('SELECT sqlite_version() AS v').get() as { v: string };\nconst [maj, min] = v.split('.').map(Number);\nconst supportsDropColumn = maj > 3 || (maj === 3 && min >= 35);\nif (!supportsDropColumn) {\n  // expect this migration to warn and retry harmlessly; plan to upgrade the runtime\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run a single worker per DB file so startup migrations never contend","Keep the runtime's SQLite at 3.35+ when migrations drop columns","Treat this warning as benign on old SQLite — it retries and mutates nothing on failure"],"tags":["sqlite","schema-migration","alter-table","pending-messages"],"backgroundTag":"sqlite-drop-column-failed","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"}