fix(db-postgres): ensure index names are not too long (#13428)

Fixes https://github.com/payloadcms/payload/issues/13196
This commit is contained in:
Sasha
2025-08-14 02:44:56 +03:00
committed by GitHub
parent c1c68fbb55
commit 047519f47f
5 changed files with 44 additions and 6 deletions

View File

@@ -9,7 +9,12 @@ export const buildIndexName = ({
name: string name: string
number?: number number?: number
}): string => { }): string => {
const indexName = `${name}${number ? `_${number}` : ''}_idx` let indexName = `${name}${number ? `_${number}` : ''}_idx`
if (indexName.length > 60) {
const suffix = `${number ? `_${number}` : ''}_idx`
indexName = `${name.slice(0, 60 - suffix.length)}${suffix}`
}
if (!adapter.indexes.has(indexName)) { if (!adapter.indexes.has(indexName)) {
adapter.indexes.add(indexName) adapter.indexes.add(indexName)

View File

@@ -44,6 +44,39 @@ export const getConfig: () => Partial<Config> = () => ({
type: 'text', type: 'text',
name: 'title', name: 'title',
}, },
{
type: 'tabs',
tabs: [
{
name: 'hideout',
fields: [
{
label: 'Cameras',
type: 'tabs',
unique: true,
tabs: [
{
name: 'camera1',
fields: [
{
type: 'row',
fields: [
{
name: 'time1Image',
type: 'relationship',
relationTo: 'posts',
unique: true,
},
],
},
],
},
],
},
],
},
],
},
], ],
}, },
{ {

View File

@@ -1,5 +1,5 @@
{ {
"id": "80e7a0d2-ffb3-4f22-8597-0442b3ab8102", "id": "fc114c71-8138-46c6-b83a-4d70e79e0ea5",
"prevId": "00000000-0000-0000-0000-000000000000", "prevId": "00000000-0000-0000-0000-000000000000",
"version": "7", "version": "7",
"dialect": "postgresql", "dialect": "postgresql",

View File

@@ -1,9 +1,9 @@
import * as migration_20250714_201659 from './20250714_201659.js' import * as migration_20250811_134524 from './20250811_134524.js'
export const migrations = [ export const migrations = [
{ {
up: migration_20250714_201659.up, up: migration_20250811_134524.up,
down: migration_20250714_201659.down, down: migration_20250811_134524.down,
name: '20250714_201659', name: '20250811_134524',
}, },
] ]