payloadcms / payloadcms/payload

dbName on blocks not propagated as prefix for nested sub-table names in versions context

Open
#16,116 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

created-by: Payload team db: postgres status: needs-triage
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
  1. with versions commented out, run pnpm payload migrate:create + pnpm payload migrate to establish the initial schema with the StickyContainers block
  2. uncomment versions in Pages
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.