{"record":{"id":"ac994ec562643761","repo":"remix-run/remix","slug":"table-tablename-primarykey-column-key-does","errorCode":null,"errorMessage":"Table \"{tableName}\" primaryKey column \"{key}\" does not exist","messagePattern":"Table \"(.+?)\" primaryKey column \"(.+?)\" does not exist","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/data-table/src/lib/table.ts","lineNumber":1109,"sourceCode":"  if (primaryKey === undefined) {\n    if (!Object.prototype.hasOwnProperty.call(columns, 'id')) {\n      throw new Error(\n        'Table \"' + tableName + '\" must include an \"id\" column or an explicit primaryKey',\n      )\n    }\n\n    return ['id']\n  }\n\n  let keys = Array.isArray(primaryKey) ? [...primaryKey] : [primaryKey]\n\n  if (keys.length === 0) {\n    throw new Error('Table \"' + tableName + '\" primaryKey must contain at least one column')\n  }\n\n  for (let key of keys) {\n    if (!Object.prototype.hasOwnProperty.call(columns, key)) {\n      throw new Error('Table \"' + tableName + '\" primaryKey column \"' + key + '\" does not exist')\n    }\n  }\n\n  return keys\n}\n\nfunction normalizeKeySelector<table extends AnyTable>(\n  table: table,\n  selector: KeySelector<table> | undefined,\n  optionName: string,\n  defaultValue: readonly string[],\n): string[] {\n  return normalizeKeysForTable(table, selector, optionName, defaultValue)\n}\n\nfunction normalizeKeysForTable(\n  table: AnyTable,\n  selector: string | readonly string[] | undefined,","sourceCodeStart":1091,"sourceCodeEnd":1127,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/data-table/src/lib/table.ts#L1091-L1127","documentation":"Each column named in the table's primaryKey option must actually exist in the columns definition. This error fires when a key column name does not match any defined column.","triggerScenarios":"primaryKey: ['userId'] when the column is defined as user_id, or after renaming/removing a column without updating the primaryKey option.","commonSituations":"Naming-convention drift (camelCase vs snake_case), partial schema migrations, or hand-written key names with typos.","solutions":["Match the primaryKey names exactly to the column keys in the definition","Rename either the column or the key so they agree","Add the missing column if it was unintentionally omitted"],"exampleFix":"// before\ncreateTable('t', { user_id: column.uuid() }, { primaryKey: ['userId'] })\n// after\ncreateTable('t', { user_id: column.uuid() }, { primaryKey: ['user_id'] })","handlingStrategy":"validation","validationCode":"for (const key of keys) {\n  if (!(key in columns)) throw new Error(`primaryKey column ${key} not defined`)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep primaryKey strings identical to column keys","Type primaryKey as (keyof typeof columns)[] where possible"],"tags":["data-table","primary-key","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}