{"record":{"id":"7580ac53a12feab0","repo":"payloadcms/payload","slug":"compound-indexes-within-localized-and-non-localize","errorCode":null,"errorMessage":"Compound indexes within localized and non localized fields are not supported in SQL. Expected ${path} to be ${someLocalized ? 'non' : ''} localized.","messagePattern":"Compound indexes within localized and non localized fields are not supported in SQL\\. Expected (.+?) to be (.+?) localized\\.","errorType":"http","errorClass":"InvalidConfiguration","httpStatus":500,"severity":"error","filePath":"packages/drizzle/src/schema/build.ts","lineNumber":305,"sourceCode":"    for (const index of compoundIndexes) {\n      let someLocalized: boolean | null = null\n      const columns: string[] = []\n\n      const getTableToUse = () => {\n        if (someLocalized) {\n          return localesTable\n        }\n\n        return table\n      }\n\n      for (const { path, pathHasLocalized } of index.fields) {\n        if (someLocalized === null) {\n          someLocalized = pathHasLocalized\n        }\n\n        if (someLocalized !== pathHasLocalized) {\n          throw new InvalidConfiguration(\n            `Compound indexes within localized and non localized fields are not supported in SQL. Expected ${path} to be ${someLocalized ? 'non' : ''} localized.`,\n          )\n        }\n\n        const columnPath = path.replaceAll('.', '_')\n\n        if (!getTableToUse().columns[columnPath]) {\n          throw new InvalidConfiguration(\n            `Column ${columnPath} for compound index on ${path} was not found in the ${getTableToUse().name} table.`,\n          )\n        }\n\n        columns.push(columnPath)\n      }\n\n      if (someLocalized) {\n        columns.push('_locale')\n      }","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/drizzle/src/schema/build.ts#L287-L323","documentation":"Thrown during schema build (build.ts) when a compound index spans both localized and non-localized fields. In the SQL adapter a localized field lives in a separate per-locale table while a non-localized field lives in the base table, so a single multi-column index cannot reference both. The adapter records the localized-ness of the first indexed field and rejects any subsequent field that differs.","triggerScenarios":"Defining an index on a field group/array where `index: [{ fields: { title: true, value: true } }]` mixes a localized field (title) with a non-localized one (value), and one or both are localized.","commonSituations":"Enabling localization on one field of an indexed group after the index was already defined; copy-pasting an index config between localized and non-localized field definitions.","solutions":["Make all fields in the compound index consistently localized or consistently non-localized.","Split the index into two separate indexes: one over the localized fields, one over the non-localized fields.","If you need a cross-cutting index, denormalize the data into a single field whose localization matches the rest of the index."],"exampleFix":"// before\nindex: [{ fields: { title: true, slug: true } }] // title localized, slug not\n// after\nindex: [{ fields: { title: true, description: true } }] // both localized","handlingStrategy":"validation","validationCode":"function assertIndexLocalityConsistent(fields, localizedSet) {\n  const localizations = Object.keys(fields).map(f => !!localizedSet[f])\n  if (localizations.some(l => l !== localizations[0])) {\n    throw new Error('Compound index mixes localized and non-localized fields')\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep compound indexes scoped to fields that share the same localization flag.","Review index definitions whenever you toggle localization on any indexed field."],"tags":["schema","index","localization","configuration"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}