﻿# `communication_logs`

**Module:** Messaging

---

## Purpose

Immutable audit log of every WhatsApp message dispatched to a guest. Tracks delivery status.

---

## Columns (Summary)

| Column | Notes |
|--------|-------|
| `id BIGINT UNSIGNED AUTO_INCREMENT PK` | — |
| `workspace_id BIGINT UNSIGNED NOT NULL FK→workspaces` | — |
| `guest_id BIGINT UNSIGNED NOT NULL FK→guests` | — |
| `template_id BIGINT UNSIGNED NOT NULL FK→message_templates` | — |
| `template_type VARCHAR(20) NOT NULL (denormalized snapshot)` | — |
| `sent_by BIGINT UNSIGNED NOT NULL FK→users` | — |
| `delivery_status VARCHAR(10) DEFAULT sent` | — |
| `sent_at DATETIME DEFAULT CURRENT_TIMESTAMP IMMUTABLE` | — |
| `delivered_at DATETIME NULL (future API)` | — |
| `read_at DATETIME NULL (future API)` | — |

---

## Referenced By

None

---

## Notes

See `docs/database/RELATIONSHIP.md` for full entity relationships and `database/schema.sql` for authoritative DDL.
