ON CONFLICT DO UPDATE requires inference specification or constraint name
- Dominant language
- Go
- Stars
- 17.2k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
- [x] The issue is present in the latest release.
- [x] I have searched the [issues](https://github.com/ent/ent/issues) of this repository and believe that this is not a duplicate.
## Current Behavior 😯
I think this is related to the ID field, it generates with two indexes:

one named `pkey` and the other named `id_key`
Code that fails: https://github.com/Southclaws/storyden/blob/main/api/src/resources/category/db.go#L24-L45
Schema: https://github.com/Southclaws/storyden/blob/main/api/src/infra/db/schema/category.go
I followed the docs here for custom ID types: https://entgo.io/docs/schema-fields#id-field and I'm probably going to switch from UUID to something like CUID in future so I want this to work without using the auto increment IDs.
## Expected Behavior 🤔
Updates/upserts to work fine with one single unique ID constraint.
Also, if there are multiple constraints, how would that be done?
## Steps to Reproduce 🕹
Grab the Storyden code above and run the test for `TestCreatePost` which initially seeds the database with users and categories, the seed data for categories is what fails.
## Your Environment 🌎
| Tech | Version |
| ----------- | ------- |
| Go | 1.18 |
| Ent | 0.10.1 |
| Database | Postgres |
| Driver | github.com/jackc/pgx/v4/stdlib |
Contributor guide
Assessment
This issue has not been assessed yet.