# `mix ash.gen.resource`
[🔗](https://github.com/ash-project/ash/blob/v3.23.1/lib/mix/tasks/gen/ash.gen.resource.ex#L6)

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

```bash
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, as `name:type`. Modifiers: `primary_key`, `array`, `public`, `sensitive`, and `required`. i.e `-a name:string:required`
* `--relationship` or `-r` - A relationship or comma separated list of relationships to add, as `type:name:dest`. Modifiers: `public` and `sensitive?`. `belongs_to` only modifiers: `primary_key` and `required`. i.e `-r belongs_to:author:MyApp.Accounts.Author:required`. For many_to_many relationship the through relationship is required between name and destination, i.e. `-r many_to_many:posts:MyApp.Blog.PostComment:MyApp.Blog.Comment:public`
* `--default-actions` - A csv list of default action types to add. The `create` and `update` 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.
* `--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 in `config :your_app, :base_resources`
* `--timestamps` or `-t` - If set adds `inserted_at` and `updated_at` timestamps to the resource.
* `--ignore-if-exists` - Does nothing if the resource already exists
* `--conflicts` - How to handle conflicts when the same attribute, relationship, or action already exists. Options: `ignore` (default), `replace`
   `ignore` will ignore your addition for that attribute, relationship, or action. `replace` will remove the existing one in favor of yours.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
