Skip to main content

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

ColumnTypeNullableDefaultDescription
iduuidNogen_random_uuid()Primary key
user_iduuidNo--Photo owner
image_urltextNo--URL to photo in storage
captiontextYes--Photo caption
alt_texttextYes--Accessibility description
positionintegerNo0Display order
created_attimestamptzNoNOW()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);

Last updated: 2026-02-07