elixir - Avinashlikes/Wiki GitHub Wiki
Elixir
-
mix phx.new <project_name> —no-html —no-webpack —database <db_type e.g. mssql>
-
mix deps.get
-
mix deps.compile
-
mix compile
-
mix test
-
mix coveralls
-
mix hex.server
-
mix release.init
Create the development database
-
Configure db connection in config/dev.exs
-
mix ecto.create. — create db
-
mix ecto.drop — drop db
-
MIX_ENV=test mix ecto.drop — crop db from test env
-
Generate the Auth context and User schema module. > mix phx.gen.context Auth User users email:string:unique password:string is_active:boolean e.g >. mix phx.gen.context Customers Customer customers CustomerName:string
Mix phx.gen.schema Customers Customer customer From above:
- Auth is the context’s module name.
- User is the schema’s module name.
- users is the DB table’s name.
- After that comes some field definitions.
- Generate migration file : > mix ecto.gen.migration <migration_name> [more help : mix help phx.gen.context]
Create DB :
- Mix ecto.create
- Mix ecto.migrate
- Mix ecto.drop
Create IEX:
- iex -S mix [from root project directory]
MIX Repo
- mix hex.repo add NAME <>
- mix hex.repo set NAME
MIX only get reps:
Mix deps.get —only hexrepo Mix deps.get —only gitrepo