Database Reference

This page lists Comms's domain tables. All tables live in your own Supabase project — not ARK's. RLS is enabled on every table.

Shared platform tables

  • profiles — user metadata.
  • workspaces — tenant boundary.
  • workspace_members — user ↔ workspace with role.
  • audit_log — who did what and when.

Comms domain tables

channels

ColumnTypeNotes
iduuid PK
workspace_iduuid FK → workspaces
nametextLowercased, unique per workspace.
kindtextpublic, private, dm, group_dm, inbox.
purposetext
retention_policytextkeep_all, 30d, 90d, 180d, 365d, custom.
retention_daysintUsed when policy = custom.
is_archivedbool
created_byuuid FK → auth.users
created_attimestamptz

channel_members

ColumnTypeNotes
channel_iduuid FK → channels
user_iduuid FK → auth.users
roletextadmin, member, guest.
notification_preftextall, mentions, none.
last_read_attimestamptzFor unread calculation.
joined_attimestamptz

messages

ColumnTypeNotes
iduuid PK
channel_iduuid FK → channels
thread_iduuid FK → messagesNullable — points to the parent message of a thread.
sender_iduuid FK → auth.users
kindtexttext, email, file, system, poll.
bodytextMarkdown.
richjsonbStructured representation (blocks, attachments, etc.).
email_headersjsonbHeaders for email-kind messages.
reply_to_iduuid FK → messagesFor email threading.
edited_attimestamptzNull if never edited.
deleted_attimestamptzSoft delete.
created_attimestamptz

message_reactions

ColumnTypeNotes
message_iduuid FK → messages
user_iduuid FK → auth.users
emojitextShortcode.
created_attimestamptz

message_pins

ColumnTypeNotes
channel_iduuid FK → channels
message_iduuid FK → messages
pinned_byuuid FK → auth.users
pinned_attimestamptz

mail_accounts

ColumnTypeNotes
iduuid PK
workspace_iduuid FK → workspaces
channel_iduuid FK → channelsInbox channel.
local_parttexte.g. support.
domaintextMatches COMMS_INBOUND_EMAIL_DOMAIN.
signaturetext
auto_rulesjsonbRouting rules.

mail_assignments

ColumnTypeNotes
message_iduuid FK → messages
assigned_touuid FK → auth.users
statustextopen, snoozed, resolved.
snooze_untiltimestamptz

huddles

ColumnTypeNotes
iduuid PK
channel_iduuid FK → channels
started_byuuid FK → auth.users
started_attimestamptz
ended_attimestamptz

huddle_participants

ColumnTypeNotes
huddle_iduuid FK → huddles
user_iduuid FK → auth.users
joined_attimestamptz
left_attimestamptz
ColumnTypeNotes
iduuid PK
channel_iduuid FK → channels
message_iduuid FK → messagesSource message.
urltextCanonicalized.
titletextOG title.
previewjsonbOG preview data.
shared_byuuid FK → auth.users
is_pinnedbool
shared_attimestamptz

channel_tasks

ColumnTypeNotes
iduuid PK
channel_iduuid FK → channels
source_message_iduuid FK → messagesNullable.
titletext
descriptiontext
assigned_touuid FK → auth.users
due_datedate
statustextopen, in_progress, done.
created_byuuid FK → auth.users
created_attimestamptz

notification_rules and notification_events

User-level rules (keywords, schedule, DND) and a log of dispatched notifications. Referenced by comms-notification-dispatcher.

search_index

Materialized tsvector + trigram index covering messages, email bodies, file names, and task titles. See Channels for syntax.

Relationships at a glance

workspaces
 └─ channels
     ├─ channel_members
     ├─ messages
     │   ├─ message_reactions
     │   ├─ message_pins
     │   └─ channel_links
     ├─ channel_tasks
     ├─ huddles
     │   └─ huddle_participants
     └─ mail_accounts
         └─ mail_assignments

RLS summary

  • Channel-scoped tables: rows visible if user_id is a member of the channel (via channel_members).
  • Workspace-scoped tables: rows visible if user_id is a workspace member.
  • Edge Functions use the service-role client for fan-out writes (inbound email, notifications, huddle signaling).