Spaces:
Sleeping
Sleeping
Upload web/lib/supabase/schema.sql
Browse files- 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
|
| 182 |
-
-- UPDATE public.profiles SET role = 'admin' WHERE email = '
|
| 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()
|