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:

Attributes

The resource fields are given using name:type syntax where type are the types supported by Ecto. Ommitting the type makes it default to :string:

mix phoenix.gen.model User users name age:integer

Furthermore an array type can also be given if it is supported by your database, although it requires the type of the underlying array element to be given too:

mix phoenix.gen.model User users nicknames:array:string

Namespaced resources

Resources can be namespaced, for such, it is just necessary to namespace the first argument of the generator:

mix phoenix.gen.model Admin.User users name:string age:integer
Source

Summary

run(arg1)

Callback implementation of Mix.Task.run/1

Functions

run(arg1)

Callback implementation of Mix.Task.run/1.

Source