mix ash.gen.resource (ash v3.4.56)
View SourceGenerate 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
--attributeor-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--relationshipor-r- A relationship or comma separated list of relationships to add, astype:name:dest. Modifiers:public.belongs_toonly 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. Thecreateandupdateactions accept the public attributes being added.--uuid-primary-keyor-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.--integer-primary-keyor-i- Adds an integer primary key with that name. i.e-i id--domainor-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.--extendor-e- A comma separated list of modules or builtins to extend the resource with. i.e-e postgres,Some.Extension--baseor-b- The base module to use for the resource. i.e-b Ash.Resource. Requires that the module is inconfig :your_app, :base_resources--timestampsor-t- If set addsinserted_atandupdated_attimestamps to the resource.