With AshPostgres, what is the proper way to create a exclusion constraint in a ash resource?

For check constraint, we can do it like this
postgres do
table "rate_plans"
repo MyApp.Repo

check_constraints do
check_constraint :start_date, "start_date_before_or_equal_to_end_date",
check: "start_date <= end_date",
message: "start_date must be before or equal to end_date"
end
end
postgres do
table "rate_plans"
repo MyApp.Repo

check_constraints do
check_constraint :start_date, "start_date_before_or_equal_to_end_date",
check: "start_date <= end_date",
message: "start_date must be before or equal to end_date"
end
end
With the above codes, when we run mix ash.codegen <filename> constraints are created. But how can we do the same for exclusion constraint? Thanks.
4 Replies
sevenseacat
sevenseacat4mo ago
it might not be supported in the DSL, but it would probably work as a custom statement
maccachan0009
maccachan0009OP4mo ago
how to do a custom statement? any example? thanks
maccachan0009
maccachan0009OP4mo ago
thanks

Did you find this page helpful?