fix(drizzle): generate the locale enum with its actual db name - #17737
Open
EugenieF wants to merge 1 commit into
Open
fix(drizzle): generate the locale enum with its actual db name#17737EugenieF wants to merge 1 commit into
EugenieF wants to merge 1 commit into
Conversation
generate:db-schema declared the locale enum as pgEnum('enum__locales', ...),
but postgres/init.ts creates that type as '_locales' — 'enum__locales' is only
the key in the adapter's enums map. Every _locale column in the generated
schema therefore referenced a type that does not exist in the database.
addEnum() already assumed name === db name, which holds for its only other
caller (columnToCodeConverter passes column.enumName, a real type name), so
this adds an optional dbName argument rather than changing that contract.
The exported const keeps the name enum__locales, since columnToCodeConverter
emits enum__locales(...) as the column builder.
Updates test/relationships/payload-generated-schema.ts, the one committed
fixture that contained the old name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #17736.
What
generate:db-schemadeclared the locale enum aspgEnum('enum__locales', …), but the adapter creates that type in Postgres as_locales—enum__localesis only the key in the adapter'senumsmap:https://github.com/payloadcms/payload/blob/main/packages/drizzle/src/postgres/init.ts#L22-L27
So every
_localecolumn in a generated schema referenced a type that does not exist in the database. Underpush: falsethe generated file is never executed, so nothing surfaced it.How
addEnum()already assumedname === db name, and that holds for its only other caller —columnToCodeConverterpassescolumn.enumName, which is a real type name. Rather than change that contract, this adds an optionaldbNamedefaulting toname, so only the locale call site behaves differently.The exported const keeps the name
enum__locales, becausecolumnToCodeConverter.ts#L17emitsenum__locales(…)as the column builder. Only the first argument topgEnumchanges.Fixture
test/relationships/payload-generated-schema.tsis the one committed fixture that contained the old name; it is updated here. The other two generated-schema fixtures undertest/are not localized and contain no locale enum.That one-line fixture change is exactly what regenerating produces — the emitted string is deterministic — but I could not run the repo's test suite locally to confirm, so CI is the real check on that file.
Verifying
Before this change, in any localized Postgres project:
while the generated schema declared
enum__locales.