Comments Logo
1.x
Essentials

Database Schema

Tables, relationships, and indexes used by the Comments package.

Tables

Five tables are created by the package migrations.

comments

The main comments table with polymorphic relationships and threading support.

ColumnTypeDescription
idbigintPrimary key
commentable_typestringPolymorphic model type
commentable_idbigintPolymorphic model ID
commenter_typestringCommenter model type
commenter_idbigintCommenter model ID
parent_idbigint (nullable)Parent comment for replies
bodytextHTML comment content
edited_attimestamp (nullable)When the comment was last edited
deleted_attimestamp (nullable)Soft delete timestamp
created_attimestamp
updated_attimestamp

Indexes: (commentable_type, commentable_id, parent_id)

comment_reactions

Tracks emoji reactions per user per comment.

ColumnTypeDescription
idbigintPrimary key
comment_idbigintForeign key to comments
commenter_typestringReactor model type
commenter_idbigintReactor model ID
reactionstringReaction key (e.g., thumbs_up)
created_attimestamp

Unique constraint: (comment_id, commenter_id, commenter_type, reaction)

comment_mentions

Tracks @mentioned users per comment.

ColumnTypeDescription
idbigintPrimary key
comment_idbigintForeign key to comments
commenter_typestringMentioned user model type
commenter_idbigintMentioned user model ID
created_attimestamp

Unique constraint: (comment_id, commenter_id, commenter_type)

comment_subscriptions

Tracks which users are subscribed to comment threads on specific models.

ColumnTypeDescription
idbigintPrimary key
commentable_typestringSubscribed model type
commentable_idbigintSubscribed model ID
commenter_typestringSubscriber model type
commenter_idbigintSubscriber model ID
created_attimestamp

Unique constraint: (commentable_type, commentable_id, commenter_type, commenter_id)

comment_attachments

Stores file attachment metadata for comments.

ColumnTypeDescription
idbigintPrimary key
comment_idbigintForeign key to comments
file_pathstringPath on the storage disk
original_namestringOriginal uploaded filename
mime_typestringFile MIME type
sizebigintFile size in bytes
diskstringLaravel filesystem disk
created_attimestamp
updated_attimestamp

Relationships

Commentable Model (e.g., Project)
  └── comments (morphMany)
        ├── commenter (morphTo → User)
        ├── parent (belongsTo → Comment)
        ├── replies (hasMany → Comment)
        ├── reactions (hasMany → Reaction)
        ├── attachments (hasMany → Attachment)
        └── mentions (morphToMany → User)

All relationships are polymorphic, allowing the same comment system to work across any number of models in your application.

Copyright © 2026