Confused with Ecto documentation


I am trying to dig deeper with Ecto and Postgres at the same time and some of the examples in the Ecto documentation are confusing. For example, I was wondering how I would add column and table constraints in a migration but looking up constraint/2 in Ecto.Migration wouldn’t tell me. The “Options” section is also confusing:


:check - The expression to evaluate on a row. Required when creating.
:name - The name of the constraint - required.

  • :name - as the function has to be called with a name (constraint(table, name, opts \\ [])) this seems to be redundant and not even used in the examples
  • :exclude - not mentioned at all yet used in the examples
  • :comment - only mentioned in the module docs for Ecto.Migration but shouldn’t it be mentioned at constraint/2 too?

Am I looking at the wrong docs?

Thank you!

This has actually been improved in current master: the docs for constraint no longer reference :name at all (for the reason you note), and includes docs for the exclude option.

Soo… huzzah! The “bug” is fixed already …

As a side note if you ever have issues with docs, the developers are really good IME at accepting pull requests that include improvements to them.

1 Like

Thanks! I’ll check the master first from now on whenever in doubt.