I have an issue where I need to set a constraint for any given set of values.
For example, if I have two columns, user_from and user_to I need to make sure if there is already a user_from with 1 and a user_to with 2 there can’t be a user_to with 1 and a user_from with 2. That is, 1 and 2 should be unique together among those columns.
This DB Stack Exchange post notes that it is possible in Postgres. But not sure how I would do this in Ecto.
I already have that constraint. That works if I try to create with the same user_from and the same user_to. But in this case, if such a record is made I want to prevent another record being made with the user from user_from as the user_to and vice versa. That doesn’t happen, and the record is inserted.