Ecto.Migration.constraint
You're seeing just the function
constraint
, go back to Ecto.Migration module for more information.
Defines a constraint (either a check constraint or an exclusion constraint) to be evaluated by the database when a row is inserted or updated.
Examples
create constraint("users", :price_must_be_positive, check: "price > 0")
create constraint("size_ranges", :no_overlap, exclude: ~s|gist (int4range("from", "to", '[]') WITH &&)|)
drop constraint("products", "price_must_be_positive")
Options
:check
- A check constraint expression. Required when creating a check constraint.:exclude
- An exclusion constraint expression. Required when creating an exclusion constraint.:prefix
- The prefix for the table.:validate
- Whether or not to validate the constraint on creation (true by default). Only available in PostgreSQL, and should be followed by a command to validate the foreign key in a following migration if false.