Skip to main content

mebook_responses

Overview

The mebook_responses table stores user answers to MeBook questions. Each response records the answer value and optionally the selected option. When a question maps to an app preference, saving a response can trigger preference updates via helper functions.

Relevant Invariants

  • Invariant #16: "AI Never Observes Individuals" -- MeBook data is used for self-reflection, not profiling
  • Invariant #14: "Privacy Is Infrastructure" -- Responses are private to the user

Schema

-- From 20260130_mebook_system.sql
CREATE TABLE mebook_responses (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
user_id UUID NOT NULL REFERENCES auth.users(id) ON DELETE CASCADE,
question_id UUID NOT NULL REFERENCES mebook_questions(id) ON DELETE CASCADE,
response_value TEXT,
selected_option_id UUID REFERENCES mebook_question_options(id),
created_at TIMESTAMPTZ DEFAULT NOW(),
updated_at TIMESTAMPTZ DEFAULT NOW(),
UNIQUE(user_id, question_id)
);

Columns

ColumnTypeNullableDefaultDescription
iduuidNogen_random_uuid()Primary key
user_iduuidNo--Responding user
question_iduuidNo--Question being answered
response_valuetextYes--Text/scale answer value
selected_option_iduuidYes--Selected option for multiple choice
created_attimestamptzNoNOW()First response timestamp
updated_attimestamptzNoNOW()Last update timestamp

RLS Policies

-- SELECT: Users can only read their own responses
CREATE POLICY "Users can view own responses"
ON mebook_responses FOR SELECT
USING (auth.uid() = user_id);

-- INSERT/UPDATE: Users can manage their own responses
CREATE POLICY "Users can upsert own responses"
ON mebook_responses FOR ALL
USING (auth.uid() = user_id);

Last updated: 2026-02-07