Skip to content
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

Postgres adapter apply only one unique constraints when there are more than one tables with the same unique fields. #4608

Closed
xiaohanyu opened this issue Dec 26, 2023 · 1 comment
Assignees
Labels
db-postgres @payloadcms/db-postgres dependency-issue The issue is in a dependency of payload - not payload itself status: needs-triage Possible bug which hasn't been reproduced yet

Comments

@xiaohanyu
Copy link

Link to reproduction

https://github.com/xiaohanyu/test-payload

Describe the Bug

Postgres only respect one unique constraints when more than one collections with the same unique fields.

To Reproduce

Steps to reproduce the bug:

  • Init a new payload app by npx create-payload-app@latest, as of now, the latest payload app is 2.5.0
  • Create two new collections, Resumes and Templates and add these two new collections to payload.config.ts
  • Start payload app by npm run dev

Check postgres table,

image

You can see that resumes table has "title_idx" UNIQUE, btree (title) where templates do not have this unique index, however, the title field in both Resumes and Templates collection are the same:

    {
      name: "title",
      label: "Title",
      type: "text",
      required: true,
      unique: true,
      minLength: 2,
      maxLength: 64,
    }

Payload Version

^2.0.0

Adapters and Plugins

db-postgres, bundler-webpack

@xiaohanyu xiaohanyu added the status: needs-triage Possible bug which hasn't been reproduced yet label Dec 26, 2023
@AlessioGr AlessioGr added the db-postgres @payloadcms/db-postgres label Dec 26, 2023
@DanRibbens DanRibbens self-assigned this Jan 2, 2024
@jmikrut jmikrut added the dependency-issue The issue is in a dependency of payload - not payload itself label Jan 8, 2024
@DanRibbens
Copy link
Contributor

Hi @xiaohanyu!

This was fixed in https://github.com/payloadcms/payload/releases/tag/v2.10.0 via #4967

Let us know if you have any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
db-postgres @payloadcms/db-postgres dependency-issue The issue is in a dependency of payload - not payload itself status: needs-triage Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

4 participants