Skip to main content

home_room_settings

Overview

The home_room_settings table stores the configuration for each user's HomeRoom -- their personal space within CommonPlace. Settings include visibility controls, theme, background customization, font, border, spacing, tagline, pronouns, and layout mode. A row is automatically created for each new user via a trigger on the profiles table.

Relevant Invariants

  • Invariant #10: "Expressive Freedom Is Spatially Contained" -- HomeRoom is the designated space for deep customization

Schema

-- From 20260130_homeroom_foundation.sql
CREATE TABLE home_room_settings (
user_id UUID PRIMARY KEY REFERENCES profiles(id) ON DELETE CASCADE,

-- Visibility
room_visibility TEXT DEFAULT 'public'
CHECK (room_visibility IN ('public', 'friends', 'circles', 'private')),

-- Theme & Style
room_theme TEXT DEFAULT 'default',
background_type TEXT DEFAULT 'solid'
CHECK (background_type IN ('solid', 'gradient', 'pattern', 'image')),
background_value TEXT DEFAULT '#fafafa',
font_voice TEXT DEFAULT 'system',
border_style TEXT DEFAULT 'none',
spacing_density TEXT DEFAULT 'comfortable'
CHECK (spacing_density IN ('comfortable', 'spacious')),

-- Header customization
tagline TEXT,
show_pronouns BOOLEAN DEFAULT FALSE,
pronouns TEXT,

created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW(),

-- Layout (added by 20260202_room_layouts.sql)
layout_mode TEXT DEFAULT 'single'
CHECK (layout_mode IN ('single', 'columns', 'freeform', 'mindmap', 'masonry', 'magazine')),
column_count INT DEFAULT 1 CHECK (column_count BETWEEN 1 AND 4),
canvas_width INT DEFAULT 1200,
canvas_height INT DEFAULT 2000,
show_connections BOOLEAN DEFAULT FALSE,
connection_style TEXT DEFAULT 'curved'
CHECK (connection_style IN ('curved', 'straight', 'stepped'))
);

Columns

ColumnTypeNullableDefaultDescription
user_iduuidNo--Primary key, references profiles(id)
room_visibilitytextNo'public'Room visibility: public, friends, circles, or private
room_themetextNo'default'Preset theme identifier
background_typetextNo'solid'Background type: solid, gradient, pattern, or image
background_valuetextNo'#fafafa'Color hex, gradient definition, or image URL
font_voicetextNo'system'Font selection from existing font system
border_styletextNo'none'Border style setting
spacing_densitytextNo'comfortable'Spacing: comfortable or spacious
taglinetextYes--Short one-line tagline
show_pronounsbooleanNoFALSEWhether to display pronouns
pronounstextYes--User's pronouns text
created_attimestamptzNoNOW()Creation timestamp
updated_attimestamptzNoNOW()Last update timestamp (auto-updated by trigger)
layout_modetextNo'single'Layout: single, columns, freeform, mindmap, masonry, magazine
column_countintNo1Number of columns for column/masonry layouts (1-4)
canvas_widthintNo1200Canvas width in pixels for freeform/mindmap layouts
canvas_heightintNo2000Canvas height in pixels for freeform/mindmap layouts
show_connectionsbooleanNoFALSEShow connection lines in mindmap mode
connection_styletextNo'curved'Connection line style: curved, straight, stepped

Triggers

-- Auto-updates updated_at on row changes
CREATE TRIGGER home_room_settings_updated
BEFORE UPDATE ON home_room_settings
FOR EACH ROW EXECUTE FUNCTION update_home_room_settings_updated_at();

A separate trigger on profiles (on_profile_created_home_room) automatically creates a default home_room_settings row and default modules whenever a new profile is inserted.

RLS Policies

-- SELECT: Public rooms visible to all; friends-only rooms visible to friends; owner always sees own
CREATE POLICY "Users can view public home rooms"
ON home_room_settings FOR SELECT TO authenticated
USING (
room_visibility = 'public'
OR user_id = auth.uid()
OR (room_visibility = 'friends' AND user_id IN (
SELECT CASE
WHEN requester_id = auth.uid() THEN addressee_id
ELSE requester_id
END
FROM friendships
WHERE status = 'accepted'
AND (requester_id = auth.uid() OR addressee_id = auth.uid())
))
);

-- ALL (INSERT/UPDATE/DELETE): Only owner can manage their own settings
CREATE POLICY "Users can manage own home room settings"
ON home_room_settings FOR ALL TO authenticated
USING (auth.uid() = user_id)
WITH CHECK (auth.uid() = user_id);

Last updated: 2026-02-07