This is a draft cheat sheet. It is a work in progress and is not finished yet.
Mix Tasks
Generate Repo: mix ecto.create |
New migration: mix ecto.gen.migration create_posts |
Migrate: mix ecto.migrate . Default all pending, options --step n, --to version_number, --all |
Rollback: mix ecto.rollback . Default latest, options --step n, --to version_number, --all |
Drop Repo (and drop everything) : mix ecto.drop |
Status: mix ecto.migrations |
Multiples DB ?: mix ecto.gen.repo . Dont forget to configure it in config.exs |
Create Table (Phoenix)
mix phx.gen.schema ModelName tablename attributes |
ModelName: should be camel cased |
tablename: should be lower cased, plural |
attribute: name:type[:modifier] |
types: :id, :interger, :float, :boolean, :string, :binary, :decimal, :utc_datetime, :array, :map, :references |
references: need a table name: user_id:references:users |
unicity: username:string:uniq |
array: emails:array:string |
|
|
|
|
|
|