{"record":{"id":"298568396738b92c","repo":"payloadcms/payload","slug":"locales-must-be-defined-for-locale-columns","errorCode":null,"errorMessage":"Locales must be defined for locale columns","messagePattern":"Locales must be defined for locale columns","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/drizzle/src/sqlite/columnToCodeConverter.ts","lineNumber":28,"sourceCode":"}) => {\n  let columnBuilderFn: string = column.type\n\n  const columnBuilderArgsArray: string[] = []\n\n  let defaultStatement: null | string = null\n\n  switch (column.type) {\n    case 'boolean': {\n      columnBuilderFn = 'integer'\n      columnBuilderArgsArray.push(\"mode: 'boolean'\")\n      break\n    }\n\n    case 'enum': {\n      let options: string[]\n      if ('locale' in column) {\n        if (!locales?.length) {\n          throw new Error('Locales must be defined for locale columns')\n        }\n        options = locales\n      } else {\n        options = column.options\n      }\n\n      columnBuilderFn = 'text'\n      columnBuilderArgsArray.push(`enum: [${options.map((locale) => `'${locale}'`).join(', ')}]`)\n\n      break\n    }\n\n    case 'geometry':\n    case 'jsonb': {\n      columnBuilderFn = 'text'\n      columnBuilderArgsArray.push(\"mode: 'json'\")\n      break\n    }","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/drizzle/src/sqlite/columnToCodeConverter.ts#L10-L46","documentation":"Thrown by the SQLite columnToCodeConverter when converting an enum column that is locale-aware (has a 'locale' key) but no locales array was supplied to the converter. For a localized enum the set of allowed values must come from the configured locale codes, so an empty/undefined locales list makes codegen impossible.","triggerScenarios":"Running the schema-to-code converter on a SQLite enum column marked as localized while the converter is invoked without a locales argument (or with an empty array).","commonSituations":"Programmatic schema introspection / codegen tooling that forgets to pass locales; disabling localization in config while legacy locale columns still exist in the DB.","solutions":["Pass the full locales array (from payload.config.localization.localeCodes) into the converter invocation.","If the column is no longer localized, migrate the DB so the column is not marked with 'locale'.","Ensure localization is enabled in the payload config before running codegen."],"exampleFix":"// before\ncolumnToCodeConverter(column, { ... }) // locales omitted\n// after\ncolumnToCodeConverter(column, { locales: payload.config.localization.localeCodes, ... })","handlingStrategy":"validation","validationCode":"function convertEnumColumn(column, locales) {\n  if ('locale' in column && (!locales || !locales.length)) {\n    throw new Error('Locales must be supplied for locale enum columns')\n  }\n}","typeGuard":"const isLocaleColumn = (c) => 'locale' in c","tryCatchPattern":null,"preventionTips":["Always thread payload.config.localization.localeCodes into any codegen that may touch locale columns.","Run codegen only against configs that have localization enabled."],"tags":["sqlite","codegen","enum","localization","tooling"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}