PhoenixKitComments.CommentMedia (PhoenixKitComments v0.2.0)

Copy Markdown View Source

Junction schema linking a comment to an uploaded file.

Mirrors PhoenixKitPosts.PostMedia — each row attaches one PhoenixKit.Modules.Storage.File to one PhoenixKitComments.Comment with a stable position and an optional caption.

Fields

  • comment_uuid - The comment this media belongs to
  • file_uuid - The Storage.File row (image / video / audio / document / other)
  • position - 1-based display order within the comment's media list
  • caption - Optional caption / alt text

Constraints

  • Unique (comment_uuid, position) so reordering can't collide
  • ON DELETE CASCADE on comment_uuid: deleting a comment row also drops its media rows
  • ON DELETE RESTRICT on file_uuid: a file may be referenced by other comments or posts, so the junction row is the only thing detaching removes; the file is reaped by the storage GC pass when no junction rows reference it.

Summary

Functions

Changeset for creating or updating a comment-media link.

Types

t()

@type t() :: %PhoenixKitComments.CommentMedia{
  __meta__: term(),
  caption: String.t() | nil,
  comment: PhoenixKitComments.Comment.t() | Ecto.Association.NotLoaded.t(),
  comment_uuid: UUIDv7.t(),
  file: PhoenixKit.Modules.Storage.File.t() | Ecto.Association.NotLoaded.t(),
  file_uuid: UUIDv7.t(),
  inserted_at: DateTime.t() | nil,
  position: integer(),
  updated_at: DateTime.t() | nil,
  uuid: UUIDv7.t() | nil
}

Functions

changeset(media, attrs)

Changeset for creating or updating a comment-media link.

Position is required and must be positive. Uniqueness on (comment_uuid, position) is enforced at the DB level.