Is it possible to add a uniqueness constraint to a Postgres text array? To clarify, I'd like to prevent duplicate instances of the same string in the same array.
I've tried a number of approaches without succes. Here's my most recent attempt:
alter table districts add constraint zip_idx exclude using gin (zip_codes with <@);
# access method "gin" does not support exclusion constraints
I've found this solution, which involves introducing a custom function, but I feel like there must be a way to handle this using one of the Gin operators or a contrib module.
Here's a baseline sqlfiddle.