# `PhoenixKit.Modules.CustomerService.TicketStatusHistory`
[🔗](https://github.com/BeamLabEU/phoenix_kit/blob/v1.7.87/lib/modules/customer_service/ticket_status_history.ex#L1)

Schema for ticket status change audit trail.

Records every status transition for a ticket, including who made
the change and an optional reason. Used for auditing and tracking
ticket lifecycle.

## Fields

- `ticket_uuid` - Reference to the ticket
- `changed_by_uuid` - User who made the status change
- `from_status` - Previous status (nil for initial creation)
- `to_status` - New status
- `reason` - Optional explanation for the change

## Examples

    # Ticket created
    %TicketStatusHistory{
      ticket_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      changed_by_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      from_status: nil,
      to_status: "open",
      reason: nil
    }

    # Ticket assigned and moved to in_progress
    %TicketStatusHistory{
      ticket_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      changed_by_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      from_status: "open",
      to_status: "in_progress",
      reason: "Assigned to support team"
    }

    # Ticket resolved
    %TicketStatusHistory{
      ticket_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      changed_by_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      from_status: "in_progress",
      to_status: "resolved",
      reason: "Issue fixed in version 2.0.1"
    }

    # Ticket reopened
    %TicketStatusHistory{
      ticket_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      changed_by_uuid: "018e3c4a-9f6b-7890-abcd-ef1234567890",
      from_status: "resolved",
      to_status: "open",
      reason: "Issue still occurring after update"
    }

# `t`

```elixir
@type t() :: %PhoenixKit.Modules.CustomerService.TicketStatusHistory{
  __meta__: term(),
  changed_by: PhoenixKit.Users.Auth.User.t() | Ecto.Association.NotLoaded.t(),
  changed_by_uuid: UUIDv7.t(),
  from_status: String.t() | nil,
  inserted_at: DateTime.t() | nil,
  reason: String.t() | nil,
  ticket:
    PhoenixKit.Modules.CustomerService.Ticket.t()
    | Ecto.Association.NotLoaded.t(),
  ticket_uuid: UUIDv7.t(),
  to_status: String.t(),
  uuid: UUIDv7.t() | nil
}
```

# `changeset`

Changeset for creating a status history entry.

## Required Fields

- `ticket_uuid` - Reference to ticket
- `changed_by_uuid` - User who made the change
- `to_status` - New status

Note: `from_status` is optional (nil for ticket creation).

# `close?`

Check if this is a close transition.

# `creation?`

Check if this is the initial creation record.

# `reopen?`

Check if this is a reopen transition.

# `resolution?`

Check if this is a resolution transition.

---

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