I have a table in Postgres with records of type [event_id, user_id, status]. The user is scoped per event, so I have a unique index on [event_id, user_id] so that a user has a unique status. The status is an enum type.
However, I can have only at most one record with status=owner.
I am trying to put a conditional index, something like [event_id, status] where "status" == "owner".
[ev, user, status]
[1, 1, owner] <- ok
[1, 2, owner] <- wrong
[1, 2, pending] <- ok
[1, 3, pending] <- ok
Any clue how to do this?