{"record":{"id":"06564fb64f5a4ded","repo":"thedotmack/claude-mem","slug":"schema-v46-target-table-target-column-row-06564f","errorCode":null,"errorMessage":"schema v46: ${target.table}.${target.column} row ${row.row_id} has unsupported ${row.storage_type} storage","messagePattern":"schema v46: (.+?)\\.(.+?) row (.+?) has unsupported (.+?) storage","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"src/services/sqlite/SessionStore.ts","lineNumber":723,"sourceCode":"        const source = columns.find(info => info.name === target.column);\n        if (!source) {\n          throw new Error(`schema v46: missing ${target.table}.${target.column}`);\n        }\n\n        for (const raw of streamRows(this.db.query(`\n          SELECT CAST(id AS TEXT) AS row_id,\n                 typeof(${target.column}) AS storage_type,\n                 CAST(${target.column} AS TEXT) AS revision\n          FROM ${target.table}\n        `))) {\n          const row = raw as { row_id: string; storage_type: string; revision: string | null };\n          if (row.storage_type === 'real') {\n            throw new Error(\n              `schema v46: ${target.table}.${target.column} row ${row.row_id} is REAL and unrecoverably rounded`\n            );\n          }\n          if (row.storage_type !== 'integer' && row.storage_type !== 'text') {\n            throw new Error(\n              `schema v46: ${target.table}.${target.column} row ${row.row_id} has unsupported ${row.storage_type} storage`\n            );\n          }\n          try {\n            assertCanonicalDecimal(row.revision, { positive: true });\n          } catch {\n            throw new Error(\n              `schema v46: ${target.table}.${target.column} row ${row.row_id} is not a positive canonical uint64 revision`\n            );\n          }\n        }\n\n        if (isText(source)) continue;\n        if (columns.some(info => info.name === target.temporary)) {\n          throw new Error(`schema v46: unexpected temporary column ${target.table}.${target.temporary}`);\n        }\n\n        this.db.run(","sourceCodeStart":705,"sourceCodeEnd":741,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/services/sqlite/SessionStore.ts#L705-L741","documentation":"During the v46 revision-affinity migration, a row's sync-revision column has a SQLite storage type other than integer or text (e.g. 'real' is handled separately, so this catches blob/null-adjacent or other odd storage). The migration only knows how to normalize integer and text values, so it fails fast.","triggerScenarios":"Streaming rows in ensureSyncRevisionTextAffinity encounters typeof(column) not in ('integer','text','real') — e.g. a BLOB-stored revision.","commonSituations":"External tooling or a different driver inserted a BLOB into the revision column; database corruption from a crashed non-SQLite writer.","solutions":["Find the offending row with: SELECT CAST(id AS TEXT), typeof(sync_rev) FROM <table> WHERE typeof(sync_rev) NOT IN ('integer','text','real')","Fix or delete the malformed row, then restart","Restore a pre-migration backup","Report as a bug with the row's storage type"],"exampleFix":"-- inspect and repair a BLOB-stored revision\nUPDATE sdk_sessions SET sync_rev = CAST(sync_rev AS TEXT) WHERE typeof(sync_rev) = 'blob';","handlingStrategy":"try-catch","validationCode":"const bad = db.query(\"SELECT COUNT(*) c FROM sdk_sessions WHERE typeof(sync_rev) NOT IN ('integer','text','real')\").get();\nif (bad.c > 0) console.error('BLOB/other storage in revision column; repair before upgrade');","typeGuard":null,"tryCatchPattern":"try { store = new SessionStore(dbPath); } catch (e) {\n  if (String(e.message).includes('unsupported') && String(e.message).startsWith('schema v46')) {\n    repairOrRestore(dbPath);\n  } else throw e;\n}","preventionTips":["Only access the DB through the library's own writers","Audit ad-hoc tooling that inserts into sync-revision columns","Back up before schema-changing upgrades"],"tags":["schema","migration","sqlite"],"backgroundTag":"schema-validation-failed","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"}