ecto-essentials
Ecto Essentials
Use this skill before modifying ANY schema, query, or migration.
Canonical FP bar: docs/fcis-engineering-rules.md — Functional Core, Imperative Shell: pure domain modules; side effects at edges. Build changesets/Multi in pure-ish functions; run Repo once at the context edge.
RULES — Follow these with no exceptions
1. Add database constraints (unique_index, foreign_key, check_constraint) AND changeset validations — both layers are required
2. Add indexes on foreign keys and frequently queried fields — never omit indexes on foreign keys
3. Parameterize all user input in queries — never interpolate values into SQL fragments, always use ^
4. Never combine schema changes and data backfill in the same migration
FCIS at this boundary
Ecto is the persistence edge. Prefer pure functions that build changesets/queries/Multi; execute with Repo once in the context shell.