-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathschema.sql
More file actions
5323 lines (3700 loc) · 149 KB
/
schema.sql
File metadata and controls
5323 lines (3700 loc) · 149 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
--
-- PostgreSQL database dump
--
\restrict MIUfT1fWtN7QgMTFqddg8XGebblgaJCidw6vMiHc3zCi6j0N0r2b5gygWEZXv5E
-- Dumped from database version 14.19 (Debian 14.19-1.pgdg13+1)
-- Dumped by pg_dump version 14.19 (Debian 14.19-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: pgcrypto; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public;
--
-- Name: EXTENSION pgcrypto; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION pgcrypto IS 'cryptographic functions';
--
-- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;
--
-- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';
--
-- Name: class_resource_type; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.class_resource_type AS ENUM (
'file',
'link'
);
--
-- Name: online_class_access_type; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.online_class_access_type AS ENUM (
'paid',
'free'
);
--
-- Name: online_classes_access_type_enum; Type: TYPE; Schema: public; Owner: -
--
CREATE TYPE public.online_classes_access_type_enum AS ENUM (
'paid',
'free'
);
--
-- Name: check_class_capacity(); Type: FUNCTION; Schema: public; Owner: -
--
CREATE FUNCTION public.check_class_capacity() RETURNS trigger
LANGUAGE plpgsql
AS $$
DECLARE
enrolled_count integer;
max_cap integer;
BEGIN
IF NEW.status = 'cancelled' THEN
RETURN NEW;
END IF;
SELECT COUNT(*) INTO enrolled_count
FROM class_enrollments
WHERE class_id = NEW.class_id AND status <> 'cancelled';
SELECT max_students INTO max_cap
FROM online_classes
WHERE id = NEW.class_id;
IF max_cap IS NOT NULL AND enrolled_count > max_cap THEN
RAISE EXCEPTION 'Class is full';
END IF;
RETURN NEW;
END;
$$;
SET default_tablespace = '';
SET default_table_access_method = heap;
--
-- Name: ad_analytics; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.ad_analytics (
ad_id uuid NOT NULL,
views integer DEFAULT 0,
clicks integer DEFAULT 0,
ctr numeric(8,4) DEFAULT '0'::numeric,
unique_viewers integer DEFAULT 0,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);
--
-- Name: ad_views; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.ad_views (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
ad_id uuid NOT NULL,
user_id uuid,
viewed_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
ip_address character varying(255),
user_agent text,
location character varying(255)
);
--
-- Name: admin_audit_logs; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.admin_audit_logs (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
admin_id uuid NOT NULL,
action character varying(255) NOT NULL,
details jsonb DEFAULT '{}'::jsonb,
ip_address character varying(255),
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: admin_profiles; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.admin_profiles (
user_id uuid NOT NULL,
job_title character varying(255),
department character varying(255),
identity_doc_url character varying(255),
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);
--
-- Name: ads; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.ads (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
title character varying(255) NOT NULL,
description text,
image_url character varying(255),
link_url character varying(255),
created_by uuid NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
video_url character varying(255),
is_active boolean DEFAULT false NOT NULL,
start_at timestamp with time zone,
end_at timestamp with time zone,
target_roles text[] DEFAULT '{}'::text[],
ad_type character varying(255),
priority integer DEFAULT 0,
allow_branding boolean DEFAULT false,
price numeric(10,2) DEFAULT '0'::numeric,
purchased_by uuid,
purchased_at timestamp with time zone
);
--
-- Name: assignment_submissions; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.assignment_submissions (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
assignment_id uuid NOT NULL,
user_id uuid NOT NULL,
file_url character varying(255),
grade integer,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
text_answer text,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: blacklisted_tokens; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.blacklisted_tokens (
id integer NOT NULL,
token_hash character varying(64) NOT NULL,
expires_at timestamp with time zone NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
token character varying(255)
);
--
-- Name: blacklisted_tokens_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.blacklisted_tokens_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: blacklisted_tokens_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.blacklisted_tokens_id_seq OWNED BY public.blacklisted_tokens.id;
--
-- Name: blog_posts; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.blog_posts (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
title character varying(255) NOT NULL,
slug character varying(255) NOT NULL,
excerpt text,
content text,
image_url character varying(255),
published_at date,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: book_cart; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.book_cart (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
student_id uuid NOT NULL,
book_id integer NOT NULL,
quantity integer DEFAULT 1 NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: book_categories; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.book_categories (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
name character varying(255) NOT NULL,
slug character varying(255) NOT NULL,
status character varying(255) DEFAULT 'active'::character varying NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);
--
-- Name: book_purchases; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.book_purchases (
id integer NOT NULL,
student_id uuid NOT NULL,
book_id integer NOT NULL,
price_paid numeric(10,2) DEFAULT '0'::numeric NOT NULL,
purchased_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: book_purchases_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.book_purchases_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: book_purchases_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.book_purchases_id_seq OWNED BY public.book_purchases.id;
--
-- Name: book_reviews; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.book_reviews (
id integer NOT NULL,
book_id integer,
user_id uuid,
rating integer NOT NULL,
comment text,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: book_reviews_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.book_reviews_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: book_reviews_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.book_reviews_id_seq OWNED BY public.book_reviews.id;
--
-- Name: book_tag_map; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.book_tag_map (
book_id integer NOT NULL,
tag_id uuid NOT NULL
);
--
-- Name: book_wishlist; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.book_wishlist (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
student_id uuid NOT NULL,
book_id integer NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: bookings; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.bookings (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
student_id uuid NOT NULL,
instructor_id uuid NOT NULL,
start_time timestamp with time zone NOT NULL,
end_time timestamp with time zone NOT NULL,
notes text,
status character varying(255) DEFAULT 'pending'::character varying,
requested_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);
--
-- Name: books; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.books (
id integer NOT NULL,
title character varying(255) NOT NULL,
detailed_description text,
price numeric(10,2) DEFAULT '0'::numeric NOT NULL,
pdf_url text,
cover_image_url text,
instructor_id uuid,
status text DEFAULT 'pending'::text NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
allow_preview boolean DEFAULT false NOT NULL,
preview_pages jsonb,
category_id uuid,
short_description text,
language character varying(255),
license_type character varying(255),
included_plans jsonb DEFAULT '[]'::jsonb NOT NULL,
CONSTRAINT books_status_check CHECK ((status = ANY (ARRAY['pending'::text, 'approved'::text, 'rejected'::text, 'active'::text, 'inactive'::text])))
);
--
-- Name: books_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.books_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: books_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.books_id_seq OWNED BY public.books.id;
--
-- Name: cart_items; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.cart_items (
id integer NOT NULL,
user_id character varying(255) NOT NULL,
item_id character varying(255) NOT NULL,
name character varying(255),
item_type character varying(255) DEFAULT 'class'::character varying NOT NULL,
price numeric(10,2) DEFAULT '0'::numeric NOT NULL,
quantity integer DEFAULT 1 NOT NULL,
added_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
reminder_sent boolean DEFAULT false
);
--
-- Name: cart_items_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.cart_items_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: cart_items_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.cart_items_id_seq OWNED BY public.cart_items.id;
--
-- Name: carts; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.carts (
user_id character varying(255) NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: categories; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.categories (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
name character varying(255) NOT NULL,
parent_id uuid,
status character varying(255) DEFAULT 'active'::character varying NOT NULL,
slug character varying(255) NOT NULL,
image_url character varying(255),
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
icon character varying(255)
);
--
-- Name: certificate_templates; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.certificate_templates (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
name character varying(255) NOT NULL,
type character varying(255) DEFAULT 'Completion'::character varying,
font_family character varying(255) DEFAULT 'Georgia, serif'::character varying,
title_font character varying(255) DEFAULT '''Great Vibes'', cursive'::character varying,
border_color character varying(255) DEFAULT '#FACC15'::character varying,
logo text,
background text,
show_qr boolean DEFAULT true,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
active boolean DEFAULT true,
sample_data jsonb DEFAULT '{}'::jsonb NOT NULL,
for_tutorials boolean DEFAULT true NOT NULL,
for_online_classes boolean DEFAULT true NOT NULL
);
--
-- Name: certificate_verifications; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.certificate_verifications (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
certificate_id uuid NOT NULL,
ip_address character varying(255),
user_agent character varying(255),
verified_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: certificates; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.certificates (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id uuid NOT NULL,
tutorial_id uuid,
class_id uuid,
template_id uuid,
certificate_code character varying(255) NOT NULL,
status text DEFAULT 'issued'::text,
revoked_at timestamp with time zone,
reason character varying(255),
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
recipient_name_override character varying(255),
instructor_name_override character varying(255),
platform_name_override character varying(255),
grade character varying(255),
verification_url character varying(255),
details jsonb,
CONSTRAINT certificates_status_check CHECK ((status = ANY (ARRAY['issued'::text, 'revoked'::text, 'pending'::text])))
);
--
-- Name: chat_moderation; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.chat_moderation (
id integer NOT NULL,
user_id uuid,
message text NOT NULL,
matched_words jsonb DEFAULT '[]'::jsonb NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
context_type character varying(255) DEFAULT 'direct_message'::character varying NOT NULL,
context_id character varying(255),
message_id integer,
severity character varying(255) DEFAULT 'medium'::character varying NOT NULL,
status character varying(255) DEFAULT 'flagged'::character varying NOT NULL,
notes text,
metadata jsonb DEFAULT '{}'::jsonb NOT NULL,
auto_action_taken boolean DEFAULT false NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: chat_moderation_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.chat_moderation_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
--
-- Name: chat_moderation_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE public.chat_moderation_id_seq OWNED BY public.chat_moderation.id;
--
-- Name: class_assignments; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.class_assignments (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
class_id uuid NOT NULL,
title character varying(255) NOT NULL,
description text,
due_date date,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
type character varying(255) DEFAULT 'text'::character varying NOT NULL,
allow_late boolean DEFAULT false NOT NULL,
time_to_finish character varying(255),
language character varying(255),
starter_code text,
grading_rubric text,
questions jsonb DEFAULT '[]'::jsonb NOT NULL,
settings jsonb,
supporting_resources jsonb
);
--
-- Name: class_attendance; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.class_attendance (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
lesson_id uuid NOT NULL,
user_id uuid NOT NULL,
attended boolean DEFAULT false,
"timestamp" timestamp with time zone DEFAULT CURRENT_TIMESTAMP,
class_id uuid NOT NULL
);
--
-- Name: class_comments; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.class_comments (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
class_id uuid NOT NULL,
user_id uuid NOT NULL,
message text NOT NULL,
parent_id uuid,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: class_enrollments; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.class_enrollments (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id uuid NOT NULL,
class_id uuid NOT NULL,
status character varying(255) DEFAULT 'enrolled'::character varying,
enrolled_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: class_lessons; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.class_lessons (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
class_id uuid NOT NULL,
title character varying(255) NOT NULL,
description text,
start_time timestamp with time zone,
"order" integer,
topic_file_url character varying(255),
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
duration integer
);
--
-- Name: class_likes; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.class_likes (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id uuid NOT NULL,
class_id uuid NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: class_reminder_subscriptions; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.class_reminder_subscriptions (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id uuid NOT NULL,
class_id uuid NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: class_resources; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.class_resources (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
class_id uuid NOT NULL,
title character varying(255) NOT NULL,
resource_type public.class_resource_type NOT NULL,
resource_url text NOT NULL,
mime_type character varying(255),
size integer,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: class_reviews; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.class_reviews (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
class_id uuid NOT NULL,
user_id uuid NOT NULL,
rating integer NOT NULL,
comment text,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: class_scoring_policies; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.class_scoring_policies (
class_id uuid NOT NULL,
assignment_weight integer DEFAULT 50,
attendance_weight integer DEFAULT 30,
final_exam_weight integer DEFAULT 20,
pass_score integer DEFAULT 60,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: class_tag_map; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.class_tag_map (
class_id uuid NOT NULL,
tag_id uuid NOT NULL
);
--
-- Name: class_tags; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.class_tags (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
name character varying(255) NOT NULL,
slug character varying(255) NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: class_views; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.class_views (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
class_id uuid NOT NULL,
viewer_id uuid,
ip_address character varying(255),
user_agent character varying(255),
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: class_wishlist; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.class_wishlist (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id uuid NOT NULL,
class_id uuid NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: community_contributors; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.community_contributors (
user_id uuid NOT NULL,
discussions_count integer DEFAULT 0 NOT NULL,
score integer DEFAULT 0 NOT NULL
);
--
-- Name: community_discussion_tags; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.community_discussion_tags (
discussion_id uuid NOT NULL,
tag_id uuid NOT NULL
);
--
-- Name: community_discussions; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.community_discussions (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id uuid NOT NULL,
title character varying(255) NOT NULL,
content text NOT NULL,
tags jsonb DEFAULT '[]'::jsonb,
image_url character varying(255),
resolved boolean DEFAULT false,
locked boolean DEFAULT false,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);
--
-- Name: community_likes; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.community_likes (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id uuid NOT NULL,
discussion_id uuid NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: community_replies; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.community_replies (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
discussion_id uuid NOT NULL,
user_id uuid NOT NULL,
content text NOT NULL,
is_answer boolean DEFAULT false,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
file_url character varying(255)
);
--
-- Name: community_reports; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.community_reports (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
reporter_id uuid NOT NULL,
discussion_id uuid,
reply_id uuid,
reason text NOT NULL,
status character varying(255) DEFAULT 'pending'::character varying,
reported_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: community_tags; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.community_tags (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
name character varying(255) NOT NULL,
slug character varying(255) NOT NULL,
active boolean DEFAULT true,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: community_views; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.community_views (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
discussion_id uuid NOT NULL,
viewer_id uuid,
ip_address character varying(255),
user_agent character varying(255),
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: community_votes; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.community_votes (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
user_id uuid NOT NULL,
discussion_id uuid NOT NULL,
vote integer NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP
);
--
-- Name: coupons; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.coupons (
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
code character varying(255) NOT NULL,
discount_percent integer NOT NULL,
expires_at timestamp with time zone,
usage_limit integer,
times_used integer DEFAULT 0,
instructor_id uuid,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
starts_at timestamp with time zone,
applies_to text,
applies_to_id uuid,
CONSTRAINT coupons_applies_to_check CHECK ((applies_to = ANY (ARRAY['tutorial'::text, 'class'::text, 'plan'::text])))
);
--
-- Name: currencies; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.currencies (
id uuid DEFAULT gen_random_uuid() NOT NULL,
label character varying(255) NOT NULL,
code character varying(255) NOT NULL,
symbol character varying(255) NOT NULL,
exchange_rate numeric(14,6) DEFAULT '1'::numeric NOT NULL,
is_active boolean DEFAULT true NOT NULL,
is_default boolean DEFAULT false NOT NULL,
auto_update boolean DEFAULT true NOT NULL,
logo_url character varying(255),
last_updated timestamp with time zone,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
tax_rate numeric(5,2) DEFAULT '0'::numeric NOT NULL
);
--
-- Name: faqs; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.faqs (
id integer NOT NULL,
question character varying(500) NOT NULL,
answer text NOT NULL,
created_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL,
updated_at timestamp with time zone DEFAULT CURRENT_TIMESTAMP NOT NULL
);
--
-- Name: faqs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE public.faqs_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;