Mix.Tasks.Phoenix.Gen.Model
Mix.Tasks.Phoenix.Gen.Model
Generates an Ecto model in your Phoenix application.
mix phoenix.gen.model User users name:string age:integer
The first argument is the module name followed by its plural name (used for the schema).
The generated model will contain:
- a schema file in web/models
- a migration file for the repository
The generated migration can be skipped with --no-migration
.
Attributes
The resource fields are given using name:type
syntax where type are the types supported by Ecto. Omitting the type makes it default to :string
:
mix phoenix.gen.model User users name age:integer
The generator also supports belongs_to
associations via references: