-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRT4.sql
More file actions
51 lines (50 loc) · 1.95 KB
/
Copy pathRT4.sql
File metadata and controls
51 lines (50 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
-- WARNING: This schema is for context only and is not meant to be run.
-- Table order and constraints may not be valid for execution.
CREATE TABLE public.teams (
name text NOT NULL,
manager_id uuid,
id uuid NOT NULL DEFAULT gen_random_uuid(),
employee_limit integer NOT NULL DEFAULT 5,
created_at timestamp with time zone DEFAULT now(),
CONSTRAINT teams_pkey PRIMARY KEY (id),
CONSTRAINT teams_manager_id_fkey FOREIGN KEY (manager_id) REFERENCES auth.users(id)
);
CREATE TABLE public.profiles (
id uuid NOT NULL,
email text NOT NULL,
team_id uuid,
current_session_token text,
last_ip text,
last_device text,
role USER-DEFINED DEFAULT 'Employee'::user_role,
is_active boolean DEFAULT true,
created_at timestamp with time zone DEFAULT now(),
full_name text,
last_login_at timestamp with time zone,
CONSTRAINT profiles_pkey PRIMARY KEY (id),
CONSTRAINT profiles_id_fkey FOREIGN KEY (id) REFERENCES auth.users(id),
CONSTRAINT profiles_team_id_fkey FOREIGN KEY (team_id) REFERENCES public.teams(id)
);
CREATE TABLE public.activity_logs (
user_id uuid,
action text NOT NULL,
details jsonb,
ip_address text,
device_info text,
id uuid NOT NULL DEFAULT gen_random_uuid(),
created_at timestamp with time zone DEFAULT now(),
CONSTRAINT activity_logs_pkey PRIMARY KEY (id),
CONSTRAINT activity_logs_user_id_fkey FOREIGN KEY (user_id) REFERENCES auth.users(id)
);
CREATE TABLE public.user_performance_logs (
user_id uuid NOT NULL,
id uuid NOT NULL DEFAULT gen_random_uuid(),
date date NOT NULL DEFAULT CURRENT_DATE,
images_moved integer NOT NULL DEFAULT 0,
images_enhanced integer NOT NULL DEFAULT 0,
active_time_minutes integer NOT NULL DEFAULT 0,
created_at timestamp with time zone NOT NULL DEFAULT now(),
updated_at timestamp with time zone NOT NULL DEFAULT now(),
CONSTRAINT user_performance_logs_pkey PRIMARY KEY (id),
CONSTRAINT user_performance_logs_user_id_fkey FOREIGN KEY (user_id) REFERENCES public.profiles(id)
);