{"record":{"id":"2ebe12ad98a175b3","repo":"payloadcms/payload","slug":"column-columnpath-for-compound-index-on-path","errorCode":null,"errorMessage":"Column ${columnPath} for compound index on ${path} was not found in the ${getTableToUse().name} table.","messagePattern":"Column (.+?) for compound index on (.+?) was not found in the (.+?) table\\.","errorType":"http","errorClass":"InvalidConfiguration","httpStatus":500,"severity":"error","filePath":"packages/drizzle/src/schema/build.ts","lineNumber":313,"sourceCode":"\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      }\n\n      let name = columns.join('_')\n      // truncate against the limit, buildIndexName will handle collisions\n      if (name.length > 63) {\n        name = 'compound_index'\n      }\n\n      const indexName = buildIndexName({ name, adapter })","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/payloadcms/payload/blob/00c58b35c0ed348ddc22daabf467b139727214fd/packages/drizzle/src/schema/build.ts#L295-L331","documentation":"Thrown during schema build when a compound index references a column path that does not exist in the resolved table (base table or, for localized fields, the locales table). The column path is derived by replacing dots with underscores; if the underlying field never produced a column, the index cannot be created.","triggerScenarios":"Declaring `index: [{ fields: { 'some.deep.path': true } }]` where the dotted path does not map to a generated column, or referencing a field name that was renamed, removed, or only present on a select/conditional sub-schema.","commonSituations":"Renaming a field but not its index entry; indexing a relationship/upload sub-field that does not become its own column; stale index config after a schema refactor.","solutions":["Verify the field path in the index exactly matches a generated column (use snake_case of the dotted path).","Remove the index entry for any field that no longer exists or that does not produce a standalone column.","If the field was renamed, update the index fields object to the new name and rebuild the schema."],"exampleFix":"// before\nindex: [{ fields: { oldName: true } }] // oldName renamed to newName\n// after\nindex: [{ fields: { newName: true } }]","handlingStrategy":"validation","validationCode":"function assertIndexColumnsExist(indexFields, tableColumns) {\n  for (const path of indexFields) {\n    const col = path.replaceAll('.', '_')\n    if (!tableColumns[col]) throw new Error(`Index references missing column ${col}`)\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["After renaming or deleting a field, grep your index configs for the old path.","Run schema build in CI to catch missing-column index errors before deploy."],"tags":["schema","index","configuration"],"backgroundTag":null,"analyzedSha":"00c58b35c0ed348ddc22daabf467b139727214fd","analyzedAt":"2026-08-12T20:45:03.758Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}