Commit 9c258bd
committed
fix(db): align ON CONFLICT clause with existing functional index
The migration script `V6.8.0.1.sql` failed with a `PSQLException` stating "there is no unique or exclusion constraint matching the ON CONFLICT specification".
This occurred because the script used a partial index syntax for the conflict target:
`ON CONFLICT (name) WHERE lang IS NULL`
However, PostgreSQL's `ON CONFLICT` inference requires the target to syntactically match an existing unique index or constraint. The actual index on the `setting` table is a functional index defined as:
`CREATE UNIQUE INDEX unique_settings ON setting (name, (COALESCE(lang, '')))`
While `WHERE lang IS NULL` and `COALESCE(lang, '')` logically handle nulls similarly for uniqueness in this context, Postgres does not treat them as interchangeable for arbiter inference.
This commit updates the migration script to explicitly target the functional index expression:
`ON CONFLICT (name, (coalesce(lang, '')))`
References:
- PostgreSQL 16 Documentation on INSERT: https://www.postgresql.org/docs/16/sql-insert.html#SQL-ON-CONFLICT1 parent 664b294 commit 9c258bd
1 file changed
+1
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
0 commit comments