profile_photos
Overview
The profile_photos table stores photos displayed in a user's HomeRoom photo gallery module. Photos have a caption, alt text for accessibility, and position ordering.
Schema
-- From 20260130_homeroom_foundation.sql
CREATE TABLE profile_photos (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
image_url TEXT NOT NULL,
caption TEXT,
alt_text TEXT,
position INTEGER DEFAULT 0,
created_at TIMESTAMPTZ DEFAULT NOW()
);
Columns
| Column | Type | Nullable | Default | Description |
|---|---|---|---|---|
id | uuid | No | gen_random_uuid() | Primary key |
user_id | uuid | No | -- | Photo owner |
image_url | text | No | -- | URL to photo in storage |
caption | text | Yes | -- | Photo caption |
alt_text | text | Yes | -- | Accessibility description |
position | integer | No | 0 | Display order |
created_at | timestamptz | No | NOW() | Upload timestamp |
RLS Policies
-- SELECT: Anyone can view profile photos (HomeRooms are visitable)
CREATE POLICY "Profile photos are publicly viewable"
ON profile_photos FOR SELECT
USING (true);
-- INSERT/UPDATE/DELETE: Users manage their own photos
CREATE POLICY "Users can manage own photos"
ON profile_photos FOR ALL
USING (auth.uid() = user_id);
Related
- home_room_settings -- Room where photos are displayed
- profiles -- Photo owner
Last updated: 2026-02-07