File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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);
You can’t perform that action at this time.
0 commit comments