Spaces:
Sleeping
Sleeping
v3.0: Update schema.sql — add admin setup command for ankygaur9972@gmail.com with admin role + pro plan
Browse files
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,
|
|
@@ -115,6 +115,8 @@ CREATE INDEX IF NOT EXISTS idx_team_invites_email ON public.team_invites(email);
|
|
| 115 |
CREATE INDEX IF NOT EXISTS idx_custom_rules_user_id ON public.custom_rules(user_id);
|
| 116 |
CREATE INDEX IF NOT EXISTS idx_custom_rules_team_id ON public.custom_rules(team_id);
|
| 117 |
CREATE INDEX IF NOT EXISTS idx_admin_logs_created ON public.admin_logs(created_at DESC);
|
|
|
|
|
|
|
| 118 |
|
| 119 |
-- ─── Row Level Security ───
|
| 120 |
ALTER TABLE public.profiles ENABLE ROW LEVEL SECURITY;
|
|
@@ -184,9 +186,11 @@ CREATE TRIGGER on_auth_user_created
|
|
| 184 |
AFTER INSERT ON auth.users
|
| 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 |
-
|
|
|
|
|
|
|
| 190 |
|
| 191 |
-- ─── Monthly reset function ───
|
| 192 |
CREATE OR REPLACE FUNCTION public.reset_monthly_usage()
|
|
|
|
| 1 |
+
-- ClauseGuard — Full Database Schema v3.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) ───
|
| 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,
|
|
|
|
| 115 |
CREATE INDEX IF NOT EXISTS idx_custom_rules_user_id ON public.custom_rules(user_id);
|
| 116 |
CREATE INDEX IF NOT EXISTS idx_custom_rules_team_id ON public.custom_rules(team_id);
|
| 117 |
CREATE INDEX IF NOT EXISTS idx_admin_logs_created ON public.admin_logs(created_at DESC);
|
| 118 |
+
CREATE INDEX IF NOT EXISTS idx_profiles_role ON public.profiles(role);
|
| 119 |
+
CREATE INDEX IF NOT EXISTS idx_profiles_email ON public.profiles(email);
|
| 120 |
|
| 121 |
-- ─── Row Level Security ───
|
| 122 |
ALTER TABLE public.profiles ENABLE ROW LEVEL SECURITY;
|
|
|
|
| 186 |
AFTER INSERT ON auth.users
|
| 187 |
FOR EACH ROW EXECUTE FUNCTION public.handle_new_user();
|
| 188 |
|
| 189 |
+
-- ─── Set owner as admin with full access ───
|
| 190 |
-- Run this AFTER your first signup with your email:
|
| 191 |
+
UPDATE public.profiles
|
| 192 |
+
SET role = 'admin', plan = 'pro'
|
| 193 |
+
WHERE email = 'ankygaur9972@gmail.com';
|
| 194 |
|
| 195 |
-- ─── Monthly reset function ───
|
| 196 |
CREATE OR REPLACE FUNCTION public.reset_monthly_usage()
|