Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions database/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,9 @@ ALTER TABLE annotations ENABLE ROW LEVEL SECURITY;
ALTER TABLE reading_sessions ENABLE ROW LEVEL SECURITY;
ALTER TABLE premium_subscriptions ENABLE ROW LEVEL SECURITY;
ALTER TABLE donations ENABLE ROW LEVEL SECURITY;
ALTER TABLE search_queries ENABLE ROW LEVEL SECURITY;
ALTER TABLE affiliate_clicks ENABLE ROW LEVEL SECURITY;
ALTER TABLE system_jobs ENABLE ROW LEVEL SECURITY;

-- Helper that returns NULL outside Supabase (so the schema still loads in plain docker)
CREATE OR REPLACE FUNCTION current_auth_uid() RETURNS UUID AS $$
Expand Down Expand Up @@ -813,6 +816,10 @@ CREATE POLICY donations_self ON donations FOR SELECT
USING (user_id = current_auth_uid() OR anonymous = FALSE);
-- Writes via service_role only.

-- search_queries, affiliate_clicks, and system_jobs hold analytics, tracking,
-- and worker audit data. Keep direct anon/authenticated access closed; server
-- routes, cron jobs, and workers should use service_role, which bypasses RLS.

-- ============================================================
-- SAMPLE DATA (dev only)
-- ============================================================
Expand Down