-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
1393 lines (951 loc) · 40.8 KB
/
Copy pathschema.sql
File metadata and controls
1393 lines (951 loc) · 40.8 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- County TimeClock database schema snapshot
-- Structure only: no employee/timekeeping rows and no secrets are included.
-- Canonical changes remain the numbered SQL migrations; regenerate this file after schema changes.
--
-- PostgreSQL database dump
--
\restrict 7gkf3OSw5xqnrsBkydZTZF5TKq0R3EvL03brpnuy237yoGCobf5xlBTvtZlB0vb
-- Dumped from database version 16.14 (Debian 16.14-1.pgdg13+1)
-- Dumped by pg_dump version 16.14 (Debian 16.14-1.pgdg13+1)
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SELECT pg_catalog.set_config('search_path', '', false);
SET check_function_bodies = false;
SET xmloption = content;
SET client_min_messages = warning;
SET row_security = off;
--
-- Name: validate_time_change_request_order(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.validate_time_change_request_order() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
existing_clock_in timestamp;
existing_clock_out timestamp;
effective_clock_in timestamp;
effective_clock_out timestamp;
BEGIN
SELECT clock_in, clock_out
INTO existing_clock_in, existing_clock_out
FROM time_entries
WHERE id = NEW.time_entry_id
AND deleted_at IS NULL;
IF NOT FOUND THEN
RAISE EXCEPTION 'Original time entry not found or has been deleted'
USING ERRCODE = '23514';
END IF;
effective_clock_in := COALESCE(NEW.requested_clock_in, existing_clock_in);
effective_clock_out := COALESCE(NEW.requested_clock_out, existing_clock_out);
IF effective_clock_out IS NOT NULL
AND effective_clock_out <= effective_clock_in THEN
RAISE EXCEPTION 'Clock out must be after clock in. Check AM/PM and the date.'
USING ERRCODE = '23514';
END IF;
RETURN NEW;
END;
$$;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: correction_requests; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.correction_requests (
id integer NOT NULL,
employee_id integer NOT NULL,
time_entry_id integer,
request_text text NOT NULL,
status text DEFAULT 'pending'::text NOT NULL,
supervisor_response text,
created_at timestamp without time zone DEFAULT now() NOT NULL,
resolved_at timestamp without time zone
);
--
-- Name: correction_requests_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.correction_requests_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: correction_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.correction_requests_id_seq OWNED BY public.correction_requests.id;
--
-- Name: department_heads; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.department_heads (
id bigint NOT NULL,
department_id integer NOT NULL,
employee_id integer NOT NULL,
active boolean DEFAULT true NOT NULL,
assigned_by integer,
assigned_at timestamp with time zone DEFAULT now() NOT NULL
);
--
-- Name: department_heads_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.department_heads_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: department_heads_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.department_heads_id_seq OWNED BY public.department_heads.id;
--
-- Name: departments; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.departments (
id integer NOT NULL,
name text NOT NULL,
active boolean DEFAULT true NOT NULL,
created_at timestamp without time zone DEFAULT now() NOT NULL,
portal_department_id uuid
);
--
-- Name: departments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.departments_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: departments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.departments_id_seq OWNED BY public.departments.id;
--
-- Name: employees; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.employees (
id integer NOT NULL,
employee_number text,
first_name text NOT NULL,
last_name text NOT NULL,
email text,
role text DEFAULT 'employee'::text NOT NULL,
is_active boolean DEFAULT true NOT NULL,
created_at timestamp without time zone DEFAULT now() NOT NULL,
pin text,
department text,
active boolean DEFAULT true NOT NULL,
department_id integer,
must_change_pin boolean DEFAULT false NOT NULL,
portal_user_id uuid,
portal_department_id uuid,
portal_permissions jsonb DEFAULT '[]'::jsonb NOT NULL,
app_admin_scope text DEFAULT 'own'::text NOT NULL,
auth_source text DEFAULT 'legacy'::text NOT NULL,
last_portal_sync_at timestamp with time zone,
access_removed_at timestamp with time zone,
directory_sync_state text DEFAULT 'unknown'::text NOT NULL,
CONSTRAINT employees_app_admin_scope_check CHECK ((app_admin_scope = ANY (ARRAY['own'::text, 'all'::text])))
);
--
-- Name: employees_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.employees_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: employees_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.employees_id_seq OWNED BY public.employees.id;
--
-- Name: leave_entries; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.leave_entries (
id bigint NOT NULL,
employee_id integer NOT NULL,
leave_date date NOT NULL,
leave_type text NOT NULL,
quarter_hours integer NOT NULL,
note text,
status text DEFAULT 'pending'::text NOT NULL,
created_by_employee_id integer NOT NULL,
reviewed_by_employee_id integer,
review_note text,
reviewed_at timestamp with time zone,
archived_at timestamp with time zone,
archived_by_employee_id integer,
archive_reason text,
created_at timestamp with time zone DEFAULT now() NOT NULL,
updated_at timestamp with time zone DEFAULT now() NOT NULL,
CONSTRAINT leave_entries_leave_type_check CHECK ((leave_type = ANY (ARRAY['vacation'::text, 'sick'::text, 'holiday'::text, 'floating_holiday'::text, 'bereavement'::text, 'jury_duty'::text, 'administrative'::text, 'other'::text]))),
CONSTRAINT leave_entries_quarter_hours_check CHECK (((quarter_hours >= 1) AND (quarter_hours <= 96))),
CONSTRAINT leave_entries_status_check CHECK ((status = ANY (ARRAY['pending'::text, 'approved'::text, 'denied'::text, 'withdrawn'::text, 'voided'::text])))
);
--
-- Name: leave_entries_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.leave_entries_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: leave_entries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.leave_entries_id_seq OWNED BY public.leave_entries.id;
--
-- Name: manual_time_entries; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.manual_time_entries (
id integer NOT NULL,
employee_id integer NOT NULL,
added_by_employee_id integer NOT NULL,
entry_type text NOT NULL,
entry_date date NOT NULL,
hours numeric(6,2) NOT NULL,
notes text,
created_at timestamp without time zone DEFAULT now() NOT NULL
);
--
-- Name: manual_time_entries_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.manual_time_entries_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: manual_time_entries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.manual_time_entries_id_seq OWNED BY public.manual_time_entries.id;
--
-- Name: pay_period_approvals; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.pay_period_approvals (
id integer NOT NULL,
employee_id integer NOT NULL,
pay_period_start date NOT NULL,
pay_period_end date NOT NULL,
employee_signed_at timestamp without time zone,
supervisor_approved_at timestamp without time zone,
supervisor_id integer,
status text DEFAULT 'open'::text NOT NULL,
created_at timestamp without time zone DEFAULT now() NOT NULL,
supervisor_employee_id integer,
payroll_finalized_at timestamp without time zone,
payroll_finalized_by integer
);
--
-- Name: pay_period_approvals_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.pay_period_approvals_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: pay_period_approvals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.pay_period_approvals_id_seq OWNED BY public.pay_period_approvals.id;
--
-- Name: portal_directory_sync_log; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.portal_directory_sync_log (
id bigint NOT NULL,
started_at timestamp with time zone DEFAULT now() NOT NULL,
completed_at timestamp with time zone,
status text DEFAULT 'running'::text NOT NULL,
received_count integer DEFAULT 0 NOT NULL,
activated_count integer DEFAULT 0 NOT NULL,
deactivated_count integer DEFAULT 0 NOT NULL,
error_message text
);
--
-- Name: portal_directory_sync_log_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.portal_directory_sync_log_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: portal_directory_sync_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.portal_directory_sync_log_id_seq OWNED BY public.portal_directory_sync_log.id;
--
-- Name: schema_migrations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.schema_migrations (
filename text NOT NULL,
checksum text NOT NULL,
applied_at timestamp with time zone DEFAULT now() NOT NULL
);
--
-- Name: settings; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.settings (
key text NOT NULL,
value text NOT NULL,
updated_at timestamp without time zone DEFAULT now() NOT NULL
);
--
-- Name: supervisor_departments; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.supervisor_departments (
id integer NOT NULL,
supervisor_employee_id integer NOT NULL,
department_id integer NOT NULL,
created_at timestamp without time zone DEFAULT now() NOT NULL
);
--
-- Name: supervisor_departments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.supervisor_departments_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: supervisor_departments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.supervisor_departments_id_seq OWNED BY public.supervisor_departments.id;
--
-- Name: supervisor_employee_assignments; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.supervisor_employee_assignments (
id bigint NOT NULL,
supervisor_employee_id integer NOT NULL,
employee_id integer NOT NULL,
department_id integer NOT NULL,
is_primary boolean DEFAULT true NOT NULL,
active boolean DEFAULT true NOT NULL,
assigned_by integer,
assigned_at timestamp with time zone DEFAULT now() NOT NULL,
ended_at timestamp with time zone,
CONSTRAINT supervisor_employee_assignments_check CHECK ((supervisor_employee_id <> employee_id))
);
--
-- Name: supervisor_employee_assignments_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.supervisor_employee_assignments_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: supervisor_employee_assignments_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.supervisor_employee_assignments_id_seq OWNED BY public.supervisor_employee_assignments.id;
--
-- Name: time_change_requests; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.time_change_requests (
id integer NOT NULL,
employee_id integer NOT NULL,
time_entry_id integer,
requested_clock_in timestamp without time zone,
requested_clock_out timestamp without time zone,
employee_reason text NOT NULL,
supervisor_id integer,
supervisor_note text,
status text DEFAULT 'pending'::text NOT NULL,
created_at timestamp without time zone DEFAULT now() NOT NULL,
reviewed_at timestamp without time zone,
employee_acknowledged_at timestamp with time zone,
archived_at timestamp with time zone,
archived_by_employee_id integer,
archive_reason text
);
--
-- Name: time_change_requests_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.time_change_requests_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: time_change_requests_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.time_change_requests_id_seq OWNED BY public.time_change_requests.id;
--
-- Name: time_entries; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.time_entries (
id integer NOT NULL,
employee_id integer NOT NULL,
clock_in timestamp without time zone NOT NULL,
clock_out timestamp without time zone,
notes text,
status text DEFAULT 'open'::text NOT NULL,
created_at timestamp without time zone DEFAULT now() NOT NULL,
deleted_at timestamp with time zone,
deleted_by_employee_id integer,
deletion_reason text,
CONSTRAINT time_entries_clock_order_check CHECK (((deleted_at IS NOT NULL) OR (clock_out IS NULL) OR (clock_out > clock_in)))
);
--
-- Name: COLUMN time_entries.deleted_at; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.time_entries.deleted_at IS 'Soft-delete timestamp. Normal application queries explicitly exclude rows where deleted_at is not null.';
--
-- Name: COLUMN time_entries.deleted_by_employee_id; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.time_entries.deleted_by_employee_id IS 'Employee account that soft-deleted this time entry.';
--
-- Name: COLUMN time_entries.deletion_reason; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON COLUMN public.time_entries.deletion_reason IS 'Required reason supplied when a punch is soft-deleted.';
--
-- Name: CONSTRAINT time_entries_clock_order_check ON time_entries; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON CONSTRAINT time_entries_clock_order_check ON public.time_entries IS 'Prevents active time entries from having a clock-out equal to or earlier than clock-in.';
--
-- Name: time_entries_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.time_entries_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: time_entries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.time_entries_id_seq OWNED BY public.time_entries.id;
--
-- Name: time_entry_audit; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.time_entry_audit (
id integer NOT NULL,
time_entry_id integer,
changed_by_employee_id integer,
old_clock_in timestamp without time zone,
old_clock_out timestamp without time zone,
new_clock_in timestamp without time zone,
new_clock_out timestamp without time zone,
reason text NOT NULL,
created_at timestamp without time zone DEFAULT now() NOT NULL
);
--
-- Name: TABLE time_entry_audit; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON TABLE public.time_entry_audit IS 'Append-only time-entry change history for the application role.';
--
-- Name: time_entry_audit_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.time_entry_audit_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: time_entry_audit_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.time_entry_audit_id_seq OWNED BY public.time_entry_audit.id;
--
-- Name: time_punch_metadata; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.time_punch_metadata (
id bigint NOT NULL,
time_entry_id integer NOT NULL,
employee_id integer NOT NULL,
punch_type text NOT NULL,
recorded_at timestamp with time zone DEFAULT now() NOT NULL,
source_ip inet,
forwarded_for text,
latitude double precision,
longitude double precision,
accuracy_meters double precision,
location_status text DEFAULT 'unavailable'::text NOT NULL,
client_source text DEFAULT 'web'::text NOT NULL,
CONSTRAINT time_punch_metadata_accuracy CHECK (((accuracy_meters IS NULL) OR (accuracy_meters >= (0)::double precision))),
CONSTRAINT time_punch_metadata_location_pair CHECK ((((latitude IS NULL) AND (longitude IS NULL)) OR (((latitude >= ('-90'::integer)::double precision) AND (latitude <= (90)::double precision)) AND ((longitude >= ('-180'::integer)::double precision) AND (longitude <= (180)::double precision))))),
CONSTRAINT time_punch_metadata_location_status_check CHECK ((location_status = ANY (ARRAY['captured'::text, 'denied'::text, 'unavailable'::text, 'timeout'::text, 'error'::text]))),
CONSTRAINT time_punch_metadata_punch_type_check CHECK ((punch_type = ANY (ARRAY['clock_in'::text, 'clock_out'::text])))
);
--
-- Name: TABLE time_punch_metadata; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON TABLE public.time_punch_metadata IS 'Append-only punch network/GPS metadata for the application role.';
--
-- Name: time_punch_metadata_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.time_punch_metadata_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: time_punch_metadata_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.time_punch_metadata_id_seq OWNED BY public.time_punch_metadata.id;
--
-- Name: timeclock_audit_log; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.timeclock_audit_log (
id bigint NOT NULL,
actor_employee_id integer,
action text NOT NULL,
target_type text,
target_id text,
details jsonb,
created_at timestamp with time zone DEFAULT now() NOT NULL
);
--
-- Name: TABLE timeclock_audit_log; Type: COMMENT; Schema: public; Owner: -
--
COMMENT ON TABLE public.timeclock_audit_log IS 'Append-only application audit log for the application role.';
--
-- Name: timeclock_audit_log_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.timeclock_audit_log_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: timeclock_audit_log_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.timeclock_audit_log_id_seq OWNED BY public.timeclock_audit_log.id;
--
-- Name: correction_requests id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.correction_requests ALTER COLUMN id SET DEFAULT nextval('public.correction_requests_id_seq'::regclass);
--
-- Name: department_heads id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.department_heads ALTER COLUMN id SET DEFAULT nextval('public.department_heads_id_seq'::regclass);
--
-- Name: departments id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.departments ALTER COLUMN id SET DEFAULT nextval('public.departments_id_seq'::regclass);
--
-- Name: employees id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.employees ALTER COLUMN id SET DEFAULT nextval('public.employees_id_seq'::regclass);
--
-- Name: leave_entries id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.leave_entries ALTER COLUMN id SET DEFAULT nextval('public.leave_entries_id_seq'::regclass);
--
-- Name: manual_time_entries id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.manual_time_entries ALTER COLUMN id SET DEFAULT nextval('public.manual_time_entries_id_seq'::regclass);
--
-- Name: pay_period_approvals id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.pay_period_approvals ALTER COLUMN id SET DEFAULT nextval('public.pay_period_approvals_id_seq'::regclass);
--
-- Name: portal_directory_sync_log id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.portal_directory_sync_log ALTER COLUMN id SET DEFAULT nextval('public.portal_directory_sync_log_id_seq'::regclass);
--
-- Name: supervisor_departments id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.supervisor_departments ALTER COLUMN id SET DEFAULT nextval('public.supervisor_departments_id_seq'::regclass);
--
-- Name: supervisor_employee_assignments id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.supervisor_employee_assignments ALTER COLUMN id SET DEFAULT nextval('public.supervisor_employee_assignments_id_seq'::regclass);
--
-- Name: time_change_requests id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.time_change_requests ALTER COLUMN id SET DEFAULT nextval('public.time_change_requests_id_seq'::regclass);
--
-- Name: time_entries id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.time_entries ALTER COLUMN id SET DEFAULT nextval('public.time_entries_id_seq'::regclass);
--
-- Name: time_entry_audit id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.time_entry_audit ALTER COLUMN id SET DEFAULT nextval('public.time_entry_audit_id_seq'::regclass);
--
-- Name: time_punch_metadata id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.time_punch_metadata ALTER COLUMN id SET DEFAULT nextval('public.time_punch_metadata_id_seq'::regclass);
--
-- Name: timeclock_audit_log id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.timeclock_audit_log ALTER COLUMN id SET DEFAULT nextval('public.timeclock_audit_log_id_seq'::regclass);
--
-- Name: correction_requests correction_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.correction_requests
ADD CONSTRAINT correction_requests_pkey PRIMARY KEY (id);
--
-- Name: department_heads department_heads_department_id_employee_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.department_heads
ADD CONSTRAINT department_heads_department_id_employee_id_key UNIQUE (department_id, employee_id);
--
-- Name: department_heads department_heads_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.department_heads
ADD CONSTRAINT department_heads_pkey PRIMARY KEY (id);
--
-- Name: departments departments_name_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.departments
ADD CONSTRAINT departments_name_key UNIQUE (name);
--
-- Name: departments departments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.departments
ADD CONSTRAINT departments_pkey PRIMARY KEY (id);
--
-- Name: employees employees_email_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.employees
ADD CONSTRAINT employees_email_key UNIQUE (email);
--
-- Name: employees employees_employee_number_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.employees
ADD CONSTRAINT employees_employee_number_key UNIQUE (employee_number);
--
-- Name: employees employees_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.employees
ADD CONSTRAINT employees_pkey PRIMARY KEY (id);
--
-- Name: leave_entries leave_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.leave_entries
ADD CONSTRAINT leave_entries_pkey PRIMARY KEY (id);
--
-- Name: manual_time_entries manual_time_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.manual_time_entries
ADD CONSTRAINT manual_time_entries_pkey PRIMARY KEY (id);
--
-- Name: pay_period_approvals pay_period_approvals_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.pay_period_approvals
ADD CONSTRAINT pay_period_approvals_pkey PRIMARY KEY (id);
--
-- Name: portal_directory_sync_log portal_directory_sync_log_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.portal_directory_sync_log
ADD CONSTRAINT portal_directory_sync_log_pkey PRIMARY KEY (id);
--
-- Name: schema_migrations schema_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.schema_migrations
ADD CONSTRAINT schema_migrations_pkey PRIMARY KEY (filename);
--
-- Name: settings settings_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.settings
ADD CONSTRAINT settings_pkey PRIMARY KEY (key);
--
-- Name: supervisor_departments supervisor_departments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.supervisor_departments
ADD CONSTRAINT supervisor_departments_pkey PRIMARY KEY (id);
--
-- Name: supervisor_departments supervisor_departments_supervisor_employee_id_department_id_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.supervisor_departments
ADD CONSTRAINT supervisor_departments_supervisor_employee_id_department_id_key UNIQUE (supervisor_employee_id, department_id);
--
-- Name: supervisor_employee_assignments supervisor_employee_assignmen_supervisor_employee_id_employ_key; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.supervisor_employee_assignments
ADD CONSTRAINT supervisor_employee_assignmen_supervisor_employee_id_employ_key UNIQUE (supervisor_employee_id, employee_id);
--
-- Name: supervisor_employee_assignments supervisor_employee_assignments_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.supervisor_employee_assignments
ADD CONSTRAINT supervisor_employee_assignments_pkey PRIMARY KEY (id);
--
-- Name: time_change_requests time_change_requests_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.time_change_requests
ADD CONSTRAINT time_change_requests_pkey PRIMARY KEY (id);
--
-- Name: time_entries time_entries_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.time_entries
ADD CONSTRAINT time_entries_pkey PRIMARY KEY (id);
--
-- Name: time_entry_audit time_entry_audit_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.time_entry_audit
ADD CONSTRAINT time_entry_audit_pkey PRIMARY KEY (id);
--
-- Name: time_punch_metadata time_punch_metadata_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.time_punch_metadata
ADD CONSTRAINT time_punch_metadata_pkey PRIMARY KEY (id);
--
-- Name: timeclock_audit_log timeclock_audit_log_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.timeclock_audit_log
ADD CONSTRAINT timeclock_audit_log_pkey PRIMARY KEY (id);