payloadcms / payloadcms/payload
dbName on blocks not propagated as prefix for nested sub-table names in versions context
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 44.8k
- Forks
- 4.2k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 53
Description
Describe the Bug
When a block has dbName set, the block's own table is correctly renamed. However, nested fields inside the block (arrays, selects with hasMany, etc.) that generate their own sub-tables still use the block's slug — not its dbName — as part of their table name prefix in the versions context. This causes a table name "..." specified more than once error in Postgres when enabling versions/drafts.
Link to the code that reproduces this issue
https://github.com/zubricks/dbname-repro
Reproduction Steps
- with versions commented out, run pnpm payload migrate:create + pnpm payload migrate to establish the initial schema with the StickyContainers block
- uncomment versions in Pages
- run pnpm payload migrate:create again — this should trigger the error
Which area(s) are affected?
db: postgres
Environment Info
Binaries:
Node: 23.11.0
npm: 11.4.2
Yarn: N/A
pnpm: 10.10.0
Relevant Packages:
payload: 3.80.0
next: 16.2.1
@payloadcms/db-postgres: 3.80.0
@payloadcms/drizzle: 3.80.0
@payloadcms/graphql: 3.80.0
@payloadcms/live-preview: 3.80.0
@payloadcms/live-preview-react: 3.80.0
@payloadcms/next/utilities: 3.80.0
@payloadcms/plugin-form-builder: 3.80.0
@payloadcms/plugin-nested-docs: 3.80.0
@payloadcms/plugin-redirects: 3.80.0
@payloadcms/plugin-search: 3.80.0
@payloadcms/plugin-seo: 3.80.0
@payloadcms/richtext-lexical: 3.80.0
@payloadcms/translations: 3.80.0
@payloadcms/ui/shared: 3.80.0
react: 19.2.4
react-dom: 19.2.4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked dbname-repro project and run the listed pnpm payload migrate:create and migrate commands, first without versions and then with versions enabled in Pages. Trace PostgreSQL table-name generation for the StickyContainers block and its nested arrays or hasMany fields; done means nested sub-table names use dbName consistently and migrations no longer report duplicate table names.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, typescript
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100