mirror of
https://github.com/zitadel/zitadel.git
synced 2024-12-20 23:07:33 +00:00
3a0f7ef193
* fix: ensure uniqueness * only update wrong ones * Update cmd/setup/16.go Co-authored-by: Silvan <silvan.reusser@gmail.com> --------- Co-authored-by: Silvan <silvan.reusser@gmail.com> (cherry picked from commit b5630411035acf521643a10527cf1abc89e7b9d3)
13 lines
533 B
SQL
13 lines
533 B
SQL
WITH casesensitive as (
|
|
SELECT instance_id, unique_type, lower(unique_field)
|
|
FROM eventstore.unique_constraints
|
|
GROUP BY instance_id, unique_type, lower(unique_field)
|
|
HAVING count(unique_field) < 2
|
|
)
|
|
UPDATE eventstore.unique_constraints c
|
|
SET unique_field = casesensitive.lower
|
|
FROM casesensitive
|
|
WHERE c.instance_id = casesensitive.instance_id
|
|
AND c.unique_type = casesensitive.unique_type
|
|
AND lower(c.unique_field) = casesensitive.lower
|
|
AND c.unique_field <> casesensitive.lower; |