Describe the Bug
Problem
PayloadCMS generates PostgreSQL index names that are excessively long and contain duplicate field name segments, causing database errors when the index name exceeds PostgreSQL's identifier length limit.
The automatic index generation creates names like:
_scenario_1_v_version_hideout_camera1_version_hideout_camera1_time2_image_idx
The segmentversion_hideout_camera1 is duplicated
Expected solution
_scenario_1_v_hideout_camera1_time2_image_idx should be the index name
Error details
⨯ [Error: Failed query: CREATE INDEX "_scenario_1_v_version_hideout_camera1_version_hideout_camera1_time2_image_idx" ON "cms"."_scenario_1_v" USING btree ("version_hideout_camera1_time2_image_id"); params: ] {
query: 'CREATE INDEX "_scenario_1_v_version_hideout_camera1_version_hideout_camera1_time2_image_idx" ON "cms"."_scenario_1_v" USING btree ("version_hideout_camera1_time2_image_id");',
params: [],
digest: '2964061673',
[cause]: [error: relation "_scenario_1_v_version_hideout_camera1_version_hideout_camera1_t" already exists] {
length: 145,
severity: 'ERROR',
code: '42P07',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'index.c',
line: '873',
routine: 'index_create'
}
}
Link to the code that reproduces this issue
/
Reproduction Steps
- Create a collection with versioning enabled (
draft: true)
- Make sure to have deeply nested fields with a
tab field
{
"slug": "scenario-1",
"admin": {
"useAsTitle": "title"
},
"versions": {
"drafts": {
"autosave": true
}
},
"fields": [
{
"type": "tabs",
"tabs": [
{
"name": "hideout",
"fields": [
{
"label": "Cameras",
"type": "tabs",
"unique": true,
"tabs": [
{
"name": "camera1",
"fields": [
{
"type": "row",
"fields": [
{
"name": "time1Image",
"type": "upload",
"relationTo": "scenario-1-image-media",
"required": true,
"unique": true
}
]
}
]
}
]
}
]
}
]
}
]
}
Which area(s) are affected? (Select all that apply)
db-postgres
Environment Info
Binaries:
Node: 22.16.0
npm: 10.9.2
Yarn: N/A
pnpm: 10.11.0
Relevant Packages:
payload: 3.47.0
next: 15.4.1
@payloadcms/db-postgres: 3.47.0
@payloadcms/email-resend: 3.47.0
@payloadcms/graphql: 3.47.0
@payloadcms/next/utilities: 3.47.0
@payloadcms/plugin-cloud-storage: 3.47.0
@payloadcms/richtext-lexical: 3.47.0
@payloadcms/storage-s3: 3.47.0
@payloadcms/translations: 3.47.0
@payloadcms/ui/shared: 3.47.0
react: 19.1.0
react-dom: 19.1.0
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 24.5.0: Tue Apr 22 19:53:27 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6041
Available memory (MB): 65536
Available CPU cores: 14
Describe the Bug
Problem
PayloadCMS generates PostgreSQL index names that are excessively long and contain duplicate field name segments, causing database errors when the index name exceeds PostgreSQL's identifier length limit.
The automatic index generation creates names like:
_scenario_1_v_version_hideout_camera1_version_hideout_camera1_time2_image_idxThe segment
version_hideout_camera1is duplicatedExpected solution
_scenario_1_v_hideout_camera1_time2_image_idxshould be the index nameError details
Link to the code that reproduces this issue
/
Reproduction Steps
draft: true)tabfieldWhich area(s) are affected? (Select all that apply)
db-postgres
Environment Info