The external_users_aliases_key UNIQUE btree constraint on the aliases text[] column only checks if the entire array is identical across rows, not whether individual elements overlap.
-- Both succeed despite sharing 'alice@example.com'
INSERT INTO external_users (..., aliases) VALUES (..., '{alice@example.com}');
INSERT INTO external_users (..., aliases) VALUES (..., '{alice@example.com,bob@example.com}');
Two external users can end up with the same alias, which breaks the assumed invariant that aliases are globally unique.
The
external_users_aliases_keyUNIQUE btree constraint on thealiases text[]column only checks if the entire array is identical across rows, not whether individual elements overlap.Two external users can end up with the same alias, which breaks the assumed invariant that aliases are globally unique.