How To: Exclusion constraints in AshPostgres

Im setting up an exclusion constraint an a few time attributes. I dont see anywhere in the docs an affordance for exclusion constraints, only check constraints, so what I did is create the migration for the exclusion manually, but now im getting an ecto error asking me to add it to the changeset.
If you would like to stop this constraint violation from raising an
exception and instead add it as an error to your changeset, please
call `exclusion_constraint/3` on your changeset with the constraint
`:name` as an option.
If you would like to stop this constraint violation from raising an
exception and instead add it as an error to your changeset, please
call `exclusion_constraint/3` on your changeset with the constraint
`:name` as an option.
Question is, is this supported? Is there a way to add the exclusion without having to do it manually for each changeset in each action?
2 Replies
barnabasj
barnabasj2y ago
I haven't used it myself but there is https://www.ash-hq.org/docs/dsl/ash-resource#postgres-exclusion_constraint_names which might help
Ash HQ
Ash.Resource
View the documentation for Ash.Resource on Ash HQ.
gordoneliel
gordonelielOP2y ago
that actually works! would be nice to have first class support for it though like we do for check contraints

Did you find this page helpful?