Skip to content

Database Schema

PostgreSQL database managed via SQLx embedded migrations.

Tables

threads

ColumnTypeDescription
idUUIDPrimary key
subjectTEXTNormalized subject line
created_atTIMESTAMPTZFirst message timestamp
updated_atTIMESTAMPTZLast message timestamp
deleted_atTIMESTAMPTZSoft-delete timestamp (nullable)

messages

ColumnTypeDescription
message_idTEXTRFC 5322 Message-ID (primary key)
thread_idUUIDFK → threads.id
inbox_idUUIDFK → inboxes.id
directionTEXTinbound or outbound
from_addressTEXTSender email
from_nameTEXTSender display name (nullable)
subjectTEXTOriginal subject
sent_atTIMESTAMPTZSend timestamp
in_reply_toTEXTParent Message-ID (nullable)
body_textTEXTPlain text body (nullable)
body_htmlTEXTHTML body (nullable)
raw_storage_keyTEXTS3 key for raw MIME
ses_message_idTEXTSES-assigned ID for delivery tracking (nullable)
created_atTIMESTAMPTZRecord creation

message_recipients

ColumnTypeDescription
idUUIDPrimary key
message_idTEXTFK → messages.message_id
recipient_typeTEXTto, cc, or bcc
addressTEXTRecipient email
nameTEXTDisplay name (nullable)

message_references

ColumnTypeDescription
idUUIDPrimary key
message_idTEXTFK → messages.message_id
referenced_idTEXTReferenced Message-ID
positionINTEGEROrder in References header

attachments

ColumnTypeDescription
idUUIDPrimary key
message_idTEXTFK → messages.message_id
filenameTEXTOriginal filename
content_typeTEXTMIME type
size_bytesBIGINTFile size
storage_keyTEXTS3 key in attachments bucket

delivery_events

ColumnTypeDescription
idUUIDPrimary key
message_idTEXTFK → messages.message_id
ses_message_idTEXTSES message ID (nullable)
statusTEXTpending, sent, delivered, bounced, complained, failed
detailsJSONBUnstructured event metadata
created_atTIMESTAMPTZEvent timestamp

webhook_endpoints

ColumnTypeDescription
idUUIDPrimary key
urlTEXTEndpoint URL
secretTEXTHMAC signing secret
eventsTEXT[]Subscribed event types
inbox_idsUUID[]Scoped inboxes (nullable, all if null)
statusTEXTactive, warning, disabled
failure_countINTEGERConsecutive failures
last_success_atTIMESTAMPTZLast successful delivery (nullable)
last_failure_atTIMESTAMPTZLast failed delivery (nullable)
created_atTIMESTAMPTZRegistration timestamp

webhook_deliveries

ColumnTypeDescription
idUUIDPrimary key
endpoint_idUUIDFK → webhook_endpoints.id
event_typeTEXTEvent type string
payloadJSONBFull event payload
statusTEXTpending, delivered, failed
attemptsINTEGERDelivery attempt count
next_attempt_atTIMESTAMPTZScheduled retry time
created_atTIMESTAMPTZEvent timestamp

suppressed_addresses

ColumnTypeDescription
addressTEXTSuppressed email (primary key)
reasonTEXTbounce or complaint
created_atTIMESTAMPTZSuppression timestamp

domains

ColumnTypeDescription
idUUIDPrimary key
nameTEXTDomain name
ses_identity_arnTEXTSES identity ARN (nullable)
dkim_tokensTEXT[]DKIM CNAME tokens
from_nameTEXTDefault sender name (nullable)
reply_to_addressTEXTDefault reply-to (nullable)
bounce_addressTEXTBounce address (nullable)
mx_verifiedBOOLEANMX record status
spf_verifiedBOOLEANSPF record status
dkim_verifiedBOOLEANDKIM record status
dmarc_verifiedBOOLEANDMARC record status
created_atTIMESTAMPTZCreation timestamp
updated_atTIMESTAMPTZUpdate timestamp
deleted_atTIMESTAMPTZSoft-delete (nullable)

inboxes

ColumnTypeDescription
idUUIDPrimary key
domain_idUUIDFK → domains.id
nameTEXTDisplay name
local_partTEXTAddress prefix
is_catchallBOOLEANCatch-all flag
created_atTIMESTAMPTZCreation timestamp
updated_atTIMESTAMPTZUpdate timestamp
deleted_atTIMESTAMPTZSoft-delete (nullable)

auth_keys

ColumnTypeDescription
idUUIDPrimary key
organization_idTEXTOwning organization
nameTEXTKey display name
public_key_pemTEXTPEM-encoded public key
algorithmTEXTES256, ES384, or RS256
created_atTIMESTAMPTZRegistration timestamp
revoked_atTIMESTAMPTZRevocation timestamp (nullable)

Indexes

Key indexes for query performance:

  • messages.thread_id — thread message listing
  • messages.inbox_id — inbox message listing
  • messages.ses_message_id — delivery event correlation
  • message_references.referenced_id — threading lookups
  • delivery_events.message_id — status queries
  • delivery_events.ses_message_id — telemetry correlation
  • suppressed_addresses.address — suppression checks
  • webhook_deliveries.status, next_attempt_at — dispatch polling
  • domains.name — domain lookups
  • inboxes.domain_id, local_part — address routing
  • auth_keys.organization_id, algorithm — key lookups