Postgres Index Name too long
Link to reproduction
No response
Describe the Bug
Payload asked me this question, and even if I accepted, I still got the message the next time I restarted the server.
You're about to add pages_blocks_highlight_list_block_locales_locale_parent_id_unique
unique constraint to the table, which contains 4 items.
If this statement fails, you will receive an error from the database.
Do you want to truncate pages_blocks_highlight_list_block_locales table?
It turns out that Postgres index name is a maximum of 63 characters long. https://til.hashrocket.com/posts/8f87c65a0a-postgresqls-max-identifier-length-is-63-bytes https://www.postgresql.org/message-id/[email protected]
So, in this case, an index named pages_blocks_highlight_list_block_locales_locale_parent_id_uni (note the missing chars) was created, but Payload did not realise this, so it continued to ask me the same question over and over.
To Reproduce
I think it should be enough to add a block in a table with a name longer than 63 characters.
Payload Version
2.12.1
Adapters and Plugins
db-postgres
Thanks, this helped me figure out a workaround by shorten the field names.
This was addressed by allowing you to customize the dbName of tables/fields where necessary. This has been introduced in both 2.x and 3.0 beta a while back. https://payloadcms.com/docs/configuration/collections#options:~:text=g.%20for%20plugins)-,dbName,-Custom%20table%20or
We also did a refactor for index names which should avoid this problem for a great many cases where it was an issue before.
Closing as this is the best workaround for now. Thanks!
This issue has been automatically locked. Please open a new issue if this issue persists with any additional detail.