Skip to main content

featured_posts

Overview

The featured_posts table tracks which posts a user has pinned to their HomeRoom. Featured posts appear in a dedicated module and have a position ordering. This lets users curate a highlight reel of their best content.

Relevant Invariants

  • Invariant #10: "Expressive Freedom Is Spatially Contained" -- Featured posts are a HomeRoom customization

Schema

-- From 20260130_homeroom_foundation.sql
CREATE TABLE featured_posts (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
post_id UUID NOT NULL REFERENCES posts(id) ON DELETE CASCADE,
position INTEGER DEFAULT 0,
created_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(user_id, post_id)
);

Columns

ColumnTypeNullableDefaultDescription
iduuidNogen_random_uuid()Primary key
user_iduuidNo--HomeRoom owner
post_iduuidNo--Featured post (cascades on delete)
positionintegerNo0Display order
created_attimestamptzNoNOW()When post was featured

RLS Policies

-- SELECT: Anyone can view featured posts (HomeRooms are visitable)
CREATE POLICY "Featured posts are publicly viewable"
ON featured_posts FOR SELECT
USING (true);

-- INSERT/DELETE: Users manage their own featured posts
CREATE POLICY "Users can manage own featured posts"
ON featured_posts FOR ALL
USING (auth.uid() = user_id);

Last updated: 2026-02-07