mix ancestry_ex.gen.schema (ancestry_ex v0.1.0)

Copy Markdown View Source

Generates an Ecto schema that uses AncestryEx, and a migration creating its table.

$ mix ancestry_ex.gen.schema Catalog.Category categories name:string position:integer

The first argument is the schema module (relative to the application module), followed by the plural name (also used as table name) and the attributes as name:type.

Supported types: string, text, integer, float, decimal, boolean, date, time, naive_datetime, utc_datetime, uuid, binary, map and array:<type>. The type defaults to string.

Options

  • --orphan-strategy - destroy (default), rootify, adopt, restrict or none.
  • --cache-depth / --virtual-depth - cache the depth in a column or in a PostgreSQL generated column.
  • --counter-cache - keep the number of children in children_count.
  • --touch - touch ancestors when a node changes.
  • --format - materialized_path2 (default) or materialized_path.
  • --column - name of the ancestry column, ancestry by default.
  • --table - the table name, defaults to the plural name.
  • --binary-id - use binary_id (UUID) primary keys.
  • --no-migration - do not generate the migration.
  • --repo and --migrations-path - see mix ancestry_ex.gen.migration.