How to add a unique index on text array column.
I have a column in my Postgres table which contains sections.
+----+-----------+
| id | sections |
|----|-----------|
| 1 |['A', 'B'] |
+----+-----------+
| 2 |['A', 'A'] |
+----+-----------+
As you can see for id 2 I can insert two sections with the same text. I do not want to add duplicate text.
I do not want duplicate sections in my column.
Is there a way I can add an index on text array.
I saw the examples for int array but can't find anything for text array
I do not want to create the new function. I want to use the existing function in Postgres.
['A', 'A']into row 2 but['A', 'B']would be allowed. Or do you want to disallow adding a row with array containingAaltogether given that there is a row with array havingA?