guestbook_entries
Overview
The guestbook_entries table stores messages left by visitors on a user's HomeRoom. Entries go through a moderation workflow -- they start as pending and must be approved by the room owner before being visible to other visitors. Room owners can also pin entries.
Relevant Invariants
- Invariant #14: "Privacy Is Infrastructure" -- Owner controls what appears on their room
- Invariant #1: "Participation Is Always Voluntary" -- Room owner moderates at their own pace
Schema
-- From 20260202_guestbook.sql
CREATE TABLE guestbook_entries (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
room_owner_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
author_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
content TEXT NOT NULL,
status TEXT DEFAULT 'pending' CHECK (status IN ('pending', 'approved', 'hidden')),
is_pinned BOOLEAN DEFAULT FALSE,
created_at TIMESTAMPTZ DEFAULT NOW(),
moderated_at TIMESTAMPTZ
);
Columns
| Column | Type | Nullable | Default | Description |
|---|---|---|---|---|
id | uuid | No | gen_random_uuid() | Primary key |
room_owner_id | uuid | No | -- | HomeRoom owner who receives the entry |
author_id | uuid | No | -- | Visitor who wrote the entry |
content | text | No | -- | Guestbook message text |
status | text | No | 'pending' | Moderation status: pending, approved, hidden |
is_pinned | boolean | No | FALSE | Whether entry is pinned to top |
created_at | timestamptz | No | NOW() | When entry was submitted |
moderated_at | timestamptz | Yes | -- | When owner moderated the entry |
RLS Policies
-- SELECT: Approved entries visible to all; pending visible to owner and author
CREATE POLICY "Approved entries are public, pending visible to owner/author"
ON guestbook_entries FOR SELECT
USING (
status = 'approved' OR
auth.uid() = room_owner_id OR
auth.uid() = author_id
);
-- INSERT: Friends can write guestbook entries
CREATE POLICY "Friends can write guestbook entries"
ON guestbook_entries FOR INSERT
WITH CHECK (auth.uid() = author_id);
-- UPDATE: Room owner can moderate entries
CREATE POLICY "Room owner can moderate entries"
ON guestbook_entries FOR UPDATE
USING (auth.uid() = room_owner_id);
Related
- home_room_settings -- Room where entries appear
- profiles -- Room owner and entry author
Last updated: 2026-02-07