Skip to content

Commit 7f2ff52

Browse files
committed
fix: add missing wakatime_stats table to canonical schema.sql (#2951)
1 parent 32007b6 commit 7f2ff52

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

supabase/schema.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,3 +334,24 @@ CREATE POLICY "Users can delete own sponsor metrics"
334334
ON user_sponsor_metrics FOR DELETE
335335
USING (auth.uid()::text = user_id);
336336

337+
-- -------------------------------------------------------
338+
-- WakaTime Stats: caches daily WakaTime coding summaries per user
339+
-- -------------------------------------------------------
340+
CREATE TABLE IF NOT EXISTS wakatime_stats (
341+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
342+
user_id TEXT NOT NULL REFERENCES users(id) ON DELETE CASCADE,
343+
date DATE NOT NULL,
344+
total_seconds INTEGER NOT NULL DEFAULT 0,
345+
languages JSONB NOT NULL DEFAULT '[]'::jsonb,
346+
projects JSONB NOT NULL DEFAULT '[]'::jsonb,
347+
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
348+
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
349+
UNIQUE(user_id, date)
350+
);
351+
352+
ALTER TABLE wakatime_stats ENABLE ROW LEVEL SECURITY;
353+
354+
DROP POLICY IF EXISTS "Users can view their own wakatime stats" ON wakatime_stats;
355+
CREATE POLICY "Users can view their own wakatime stats"
356+
ON wakatime_stats FOR SELECT
357+
USING (auth.uid()::text = user_id);

0 commit comments

Comments
 (0)