{"record":{"id":"2f20d1a7dfe4cd0b","repo":"remix-run/remix","slug":"table-tablename-must-include-an-id-column-or","errorCode":null,"errorMessage":"Table \"{tableName}\" must include an \"id\" column or an explicit primaryKey","messagePattern":"Table \"(.+?)\" must include an \"id\" column or an explicit primaryKey","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/data-table/src/lib/table.ts","lineNumber":1093,"sourceCode":"  if (typeof value === 'string') {\n    return JSON.stringify(value)\n  }\n\n  if (value instanceof Date) {\n    return 'date:' + value.toISOString()\n  }\n\n  return JSON.stringify(value)\n}\n\nfunction normalizePrimaryKey(\n  tableName: string,\n  columns: TableColumnsDefinition,\n  primaryKey?: string | readonly string[],\n): string[] {\n  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  }","sourceCodeStart":1075,"sourceCodeEnd":1111,"githubUrl":"https://github.com/remix-run/remix/blob/9696913134be3a4423513d2775f7b31d6917c049/packages/data-table/src/lib/table.ts#L1075-L1111","documentation":"Every table needs a primary key for row identity and relations. If you do not pass an explicit primaryKey option, the library defaults to an 'id' column, and this error fires when the columns definition has neither an 'id' column nor an explicit primaryKey.","triggerScenarios":"createTable('users', { email: column.string() }) with no primaryKey option, or renaming the id column (e.g. userId) without adding primaryKey: 'userId'.","commonSituations":"Legacy tables with non-id keys, generated schemas that omit id, or accidental deletion of the id column during a refactor.","solutions":["Add an id: column.id() (or equivalent) column to the definition","Or pass primaryKey: 'yourKeyColumn' / primaryKey: ['a','b'] to createTable","If the table truly has no key, reconsider — relations and lookups require one"],"exampleFix":"// before\nconst users = createTable('users', {\n  email: column.string(),\n})\n// after\nconst users = createTable('users', {\n  userId: column.uuid(),\n  email: column.string(),\n}, { primaryKey: 'userId' })","handlingStrategy":"validation","validationCode":"if (!('id' in columns) && !options?.primaryKey) throw new Error('table needs id or primaryKey')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always define a key column explicitly in every table","Add a lint/review check that createTable calls include primaryKey or id"],"tags":["data-table","primary-key","schema"],"backgroundTag":"missing-primary-key","analyzedSha":"9696913134be3a4423513d2775f7b31d6917c049","analyzedAt":"2026-08-27T19:55:01.024Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}