Ash FrameworkAF
Ash Framework8mo ago
5 replies
maccachan0009

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


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.
Was this page helpful?