Junction schema for ticket and comment attachments.
Links tickets or comments to uploaded files (images, documents, etc.) with ordering and optional captions. An attachment belongs to either a ticket directly OR a comment, but not both.
Fields
ticket_id- Reference to ticket (if attached to ticket directly)comment_id- Reference to comment (if attached to comment)file_id- Reference to the uploaded file (PhoenixKit.Storage.File)position- Display order (1, 2, 3, etc.)caption- Optional caption/alt text
Note: Either ticket_id OR comment_id must be set, but not both.
Examples
# Attachment on ticket itself
%TicketAttachment{
ticket_id: "018e3c4a-9f6b-7890-abcd-ef1234567890",
comment_id: nil,
file_id: "018e3c4a-1234-5678-abcd-ef1234567890",
position: 1,
caption: "Screenshot of the error"
}
# Attachment on a comment
%TicketAttachment{
ticket_id: nil,
comment_id: "018e3c4a-5678-1234-abcd-ef1234567890",
file_id: "018e3c4a-abcd-efgh-ijkl-mnopqrstuvwx",
position: 1,
caption: nil
}
Summary
Functions
Changeset for creating or updating an attachment.
Check if attachment is attached to a comment.
Check if attachment is attached to a ticket directly.
Types
@type t() :: %PhoenixKit.Modules.Tickets.TicketAttachment{ __meta__: term(), caption: String.t() | nil, comment: PhoenixKit.Modules.Tickets.TicketComment.t() | Ecto.Association.NotLoaded.t() | nil, comment_id: UUIDv7.t() | nil, file: PhoenixKit.Modules.Storage.File.t() | Ecto.Association.NotLoaded.t(), file_id: UUIDv7.t(), inserted_at: NaiveDateTime.t() | nil, position: integer(), ticket: PhoenixKit.Modules.Tickets.Ticket.t() | Ecto.Association.NotLoaded.t() | nil, ticket_id: UUIDv7.t() | nil, updated_at: NaiveDateTime.t() | nil, uuid: UUIDv7.t() | nil }
Functions
Changeset for creating or updating an attachment.
Required Fields
file_id- Reference to fileposition- Display order (must be positive)- Either
ticket_idORcomment_id(but not both)
Validation Rules
- Position must be greater than 0
- Must have exactly one of ticket_id or comment_id
Check if attachment is attached to a comment.
Check if attachment is attached to a ticket directly.