Ecto

Commands

  • mix ecto.gen.migration…
  • mix ecto.migrate
  • mix run priv/repo/seeds.exs

Concepts

  • changeset: handles data validation and typecasting. Returned by a function within the repo module
  • context: a grouping of stuff
  • migration: applies changes to DB
  • repo: module that provides CRUD and other operations
  • schema: map elixir data types to and from external sources (equivalent to a model). Also defines an Elixir struct for it

Migration Command

$ mix ecto.gen.migration Context Schema table_plural field:type schema_id:references:schema

Field Types

https://phoenix.hexdocs.pm/Mix.Tasks.Phx.Gen.Schema.html