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
| Column | Type | Nullable | Default | Description |
|---|---|---|---|---|
user_id | uuid | No | -- | Primary key, references profiles(id) |
room_visibility | text | No | 'public' | Room visibility: public, friends, circles, or private |
room_theme | text | No | 'default' | Preset theme identifier |
background_type | text | No | 'solid' | Background type: solid, gradient, pattern, or image |
background_value | text | No | '#fafafa' | Color hex, gradient definition, or image URL |
font_voice | text | No | 'system' | Font selection from existing font system |
border_style | text | No | 'none' | Border style setting |
spacing_density | text | No | 'comfortable' | Spacing: comfortable or spacious |
tagline | text | Yes | -- | Short one-line tagline |
show_pronouns | boolean | No | FALSE | Whether to display pronouns |
pronouns | text | Yes | -- | User's pronouns text |
created_at | timestamptz | No | NOW() | Creation timestamp |
updated_at | timestamptz | No | NOW() | Last update timestamp (auto-updated by trigger) |
layout_mode | text | No | 'single' | Layout: single, columns, freeform, mindmap, masonry, magazine |
column_count | int | No | 1 | Number of columns for column/masonry layouts (1-4) |
canvas_width | int | No | 1200 | Canvas width in pixels for freeform/mindmap layouts |
canvas_height | int | No | 2000 | Canvas height in pixels for freeform/mindmap layouts |
show_connections | boolean | No | FALSE | Show connection lines in mindmap mode |
connection_style | text | No | '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);
Related
- home_room_modules -- Modules placed in this room
- profiles -- Room owner
Last updated: 2026-02-07