shelves
Overview
Shelves are user-created folders for organizing saved posts. Each shelf has a name and a position for custom ordering. Shelves are entirely private to the user.
Schema
-- Pre-existing table (inferred from frontend code)
CREATE TABLE shelves (
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
user_id UUID REFERENCES auth.users(id) NOT NULL,
name TEXT NOT NULL,
position INTEGER DEFAULT 0,
created_at TIMESTAMPTZ DEFAULT NOW()
);
Columns
| Column | Type | Nullable | Default | Description |
|---|---|---|---|---|
id | uuid | No | uuid_generate_v4() | Primary key |
user_id | uuid | No | -- | Shelf owner |
name | text | No | -- | Shelf display name |
position | integer | No | 0 | Sort order among user shelves |
created_at | timestamptz | No | NOW() | Creation timestamp |
RLS Policies
-- SELECT: Users can only see their own shelves
CREATE POLICY "Users can view own shelves"
ON shelves FOR SELECT
USING (auth.uid() = user_id);
-- INSERT: Users can create shelves
CREATE POLICY "Users can create shelves"
ON shelves FOR INSERT
WITH CHECK (auth.uid() = user_id);
-- UPDATE: Users can rename/reorder shelves
CREATE POLICY "Users can update own shelves"
ON shelves FOR UPDATE
USING (auth.uid() = user_id);
-- DELETE: Users can delete shelves
CREATE POLICY "Users can delete own shelves"
ON shelves FOR DELETE
USING (auth.uid() = user_id);
Related
- saved_posts -- Posts organized into this shelf
Last updated: 2026-02-07