-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Payload creates too long names/identifiers for postgress #12094
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm not sure if CONSTRAINTS also fall under the 63 char limit... Some of them also get way longer then 63 chars in my migrations. All with (what I believe) reasonable names Here is a relation from collection
|
Thanks @RafalFilipek! This is really helpful. I'd still suggest to warn/error pro-actively. This is does not fail gracefully - in my case I only found out when trying to migrate things on the tables that are already in prod. |
Simply using custom
I then went ahead and used
Edit: Using a hash here felt off, so I created a more explicit mapping, effectively doing this: {
/* ... */
dbName: ({ tableName }) => {
const relationTables = {
parent: 'xyz',
_parent_v: 'abcv'
}
if (!relationTables[tableName]) {
throw new Error('unexpected relation');
}
return relationTables[tableName]
}
} I don't have capacity to dig any further right now, It feels like the combination with localization and versioning still produces naming collisions somehow. Happy to assist with debugging this |
Describe the Bug
Given I use payload with a postgress database
When combining features like nested arrays, localization and versioning
Then payload creates too long index and table names like
_users_v_version_ingredient_sections_section_ingredients_locale_idx
Then Postgress like Neon with Vercel then truncates this to use only the first 63 chars
And that creates all sorts of problems (I assume)
On my end this surfaced when I removed some of the features that created the long index
Thereby creating a migration dropping the index and altering tables
Which postgress takes only 63 chars of thereby failing.
Link to the code that reproduces this issue
https://github.com/Xiphe/payload-long-index-names
Reproduction Steps
pnpm install
pnpm payload migrate
Which area(s) are affected? (Select all that apply)
db-postgres
Environment Info
The text was updated successfully, but these errors were encountered: