Feat(utils): psql unique index instead of constraint (#6386)

**What**
- always return an index expression, also for unique constraints

**why**
- constraints can't be partial, meaning `UNIQUE ... WHERE` is not possible with constraints
- constraints are indicies under the hood so it doesn't change the behavior of the system when we're not using constraint specific features but just using them for `UNIQUE`
This commit is contained in:
Philip Korsholm
2024-02-13 08:07:34 +00:00
committed by GitHub
parent aa9f66e16a
commit a86c87fe14
3 changed files with 10 additions and 8 deletions
@@ -73,9 +73,9 @@ describe("createPsqlIndexStatementHelper", function () {
const indexStatement = createPsqlIndexStatementHelper(options)
expect(indexStatement).toEqual(
`ALTER TABLE IF EXISTS "${options.tableName}" ADD CONSTRAINT "${
options.name
}" UNIQUE (${options.columns.join(", ")}) WHERE ${options.where}`
`CREATE UNIQUE INDEX IF NOT EXISTS "${options.name}" ON "${
options.tableName
}" (${options.columns.join(", ")}) WHERE ${options.where}`
)
})
})