View Source mix ash.gen.resource (ash v3.4.36)
Generate and configure an Ash.Resource.
If the domain does not exist, we create it. If it does, we add the resource to it if it is not already present.
Example
mix ash.gen.resource Helpdesk.Support.Ticket \
--default-actions read \
--uuid-primary-key id \
--attribute subject:string:required:public \
--relationship belongs_to:representative:Helpdesk.Support.Representative \
--timestamps \
--extend postgres,graphql
Options
--attribute
or-a
- An attribute or comma separated list of attributes to add, asname:type
. Modifiers:primary_key
,public
,sensitive
, andrequired
. i.e-a name:string:required
--relationship
or-r
- A relationship or comma separated list of relationships to add, astype:name:dest
. Modifiers:public
.belongs_to
only modifiers:primary_key
,sensitive
, andrequired
. i.e-r belongs_to:author:MyApp.Accounts.Author:required
--default-actions
- A csv list of default action types to add, i.e-da read,create
. Thecreate
andupdate
actions accept the public attributes being added.--uuid-primary-key
or-u
- Adds a UUIDv4 primary key with that name. i.e-u id
--uuid-v7-primary-key
- Adds a UUIDv7 primary key with that name. i.e-u7 id
--integer-primary-key
or-i
- Adds an integer primary key with that name. i.e-i id
--domain
or-d
- The domain module to add the resource to. i.e-d MyApp.MyDomain
. This defaults to the resource's module name, minus the last segment.--extend
or-e
- A comma separated list of modules or builtins to extend the resource with. i.e-e postgres,Some.Extension
--base
or-b
- The base module to use for the resource. i.e-b Ash.Resource
. Requires that the module is inconfig :your_app, :base_resources
--timestamps
or-t
- If set addsinserted_at
andupdated_at
timestamps to the resource.