gaurv007 commited on
Commit
ea2f207
Β·
verified Β·
1 Parent(s): 977e6a7

Upload web/lib/supabase/schema.sql

Browse files
Files changed (1) hide show
  1. web/lib/supabase/schema.sql +11 -4
web/lib/supabase/schema.sql CHANGED
@@ -1,4 +1,4 @@
1
- -- ClauseGuard β€” Full Database Schema
2
  -- Tables ordered by dependency (no forward references)
3
 
4
  -- ─── 1. Teams (no dependencies) ───
@@ -42,7 +42,7 @@ CREATE TABLE IF NOT EXISTS public.team_invites (
42
  UNIQUE(team_id, email)
43
  );
44
 
45
- -- ─── 4. Analyses (depends on profiles, teams) ───
46
  CREATE TABLE IF NOT EXISTS public.analyses (
47
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
48
  user_id UUID REFERENCES public.profiles ON DELETE CASCADE NOT NULL,
@@ -54,6 +54,13 @@ CREATE TABLE IF NOT EXISTS public.analyses (
54
  risk_score INT NOT NULL CHECK (risk_score >= 0 AND risk_score <= 100),
55
  grade CHAR(1) NOT NULL CHECK (grade IN ('A', 'B', 'C', 'D', 'F')),
56
  clauses JSONB NOT NULL DEFAULT '[]',
 
 
 
 
 
 
 
57
  created_at TIMESTAMPTZ DEFAULT NOW()
58
  );
59
 
@@ -178,8 +185,8 @@ CREATE TRIGGER on_auth_user_created
178
  FOR EACH ROW EXECUTE FUNCTION public.handle_new_user();
179
 
180
  -- ─── Set admin ───
181
- -- Run this AFTER your first signup with ankygaur9972@gmail.com:
182
- -- UPDATE public.profiles SET role = 'admin' WHERE email = 'ankygaur9972@gmail.com';
183
 
184
  -- ─── Monthly reset function ───
185
  CREATE OR REPLACE FUNCTION public.reset_monthly_usage()
 
1
+ -- ClauseGuard β€” Full Database Schema v2.0
2
  -- Tables ordered by dependency (no forward references)
3
 
4
  -- ─── 1. Teams (no dependencies) ───
 
42
  UNIQUE(team_id, email)
43
  );
44
 
45
+ -- ─── 4. Analyses (depends on profiles, teams) β€” v2.0 with full analysis data ───
46
  CREATE TABLE IF NOT EXISTS public.analyses (
47
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
48
  user_id UUID REFERENCES public.profiles ON DELETE CASCADE NOT NULL,
 
54
  risk_score INT NOT NULL CHECK (risk_score >= 0 AND risk_score <= 100),
55
  grade CHAR(1) NOT NULL CHECK (grade IN ('A', 'B', 'C', 'D', 'F')),
56
  clauses JSONB NOT NULL DEFAULT '[]',
57
+ entities JSONB DEFAULT '[]',
58
+ contradictions JSONB DEFAULT '[]',
59
+ obligations JSONB DEFAULT '[]',
60
+ compliance JSONB DEFAULT '{}',
61
+ raw_text TEXT,
62
+ model TEXT DEFAULT 'regex',
63
+ latency_ms INT DEFAULT 0,
64
  created_at TIMESTAMPTZ DEFAULT NOW()
65
  );
66
 
 
185
  FOR EACH ROW EXECUTE FUNCTION public.handle_new_user();
186
 
187
  -- ─── Set admin ───
188
+ -- Run this AFTER your first signup with your email:
189
+ -- UPDATE public.profiles SET role = 'admin' WHERE email = 'your-email@example.com';
190
 
191
  -- ─── Monthly reset function ───
192
  CREATE OR REPLACE FUNCTION public.reset_monthly_usage()