DatabaseCreation-AdvDb: ddl.sql

File ddl.sql, 35.8 KB (added by 231175, 3 weeks ago)
Line 
1
2 create sequence _order_seq start with 1 increment by 50;
3
4 create sequence _user_seq start with 1 increment by 50;
5
6 create sequence admin_seq start with 1 increment by 50;
7
8 create sequence bundle_seq start with 1 increment by 50;
9
10 create sequence bundle_translation_seq start with 1 increment by 50;
11
12 create sequence certificate_seq start with 1 increment by 50;
13
14 create sequence course_activity_event_seq start with 1 increment by 50;
15
16 create sequence course_lecture_seq start with 1 increment by 50;
17
18 create sequence course_lecture_translation_seq start with 1 increment by 50;
19
20 create sequence course_module_seq start with 1 increment by 50;
21
22 create sequence course_module_translation_seq start with 1 increment by 50;
23
24 create sequence course_price_seq start with 1 increment by 50;
25
26 create sequence course_seq start with 1 increment by 50;
27
28 create sequence course_translation_seq start with 1 increment by 50;
29
30 create sequence course_version_seq start with 1 increment by 50;
31
32 create sequence curated_bundle_seq start with 1 increment by 50;
33
34 create sequence curated_learning_path_seq start with 1 increment by 50;
35
36 create sequence enrollment_seq start with 1 increment by 50;
37
38 create sequence expert_seq start with 1 increment by 50;
39
40 create sequence language_seq start with 1 increment by 50;
41
42 create sequence learning_path_course_seq start with 1 increment by 50;
43
44 create sequence learning_path_seq start with 1 increment by 50;
45
46 create sequence learning_path_translation_seq start with 1 increment by 50;
47
48 create sequence lecture_progress_seq start with 1 increment by 50;
49
50 create sequence meeting_email_reminder_seq start with 1 increment by 50;
51
52 create sequence order_details_seq start with 1 increment by 50;
53
54 create sequence payment_seq start with 1 increment by 50;
55
56 create sequence personalized_bundle_seq start with 1 increment by 50;
57
58 create sequence personalized_learning_path_seq start with 1 increment by 50;
59
60 create sequence quiz_answer_option_seq start with 1 increment by 50;
61
62 create sequence quiz_answer_option_translation_seq start with 1 increment by 50;
63
64 create sequence quiz_attempt_answer_seq start with 1 increment by 50;
65
66 create sequence quiz_attempt_seq start with 1 increment by 50;
67
68 create sequence quiz_question_seq start with 1 increment by 50;
69
70 create sequence quiz_question_skill_seq start with 1 increment by 50;
71
72 create sequence quiz_question_translation_seq start with 1 increment by 50;
73
74 create sequence quiz_seq start with 1 increment by 50;
75
76 create sequence quiz_translation_seq start with 1 increment by 50;
77
78 create sequence related_course_seq start with 1 increment by 50;
79
80 create sequence review_seq start with 1 increment by 50;
81
82 create sequence skill_seq start with 1 increment by 50;
83
84 create sequence skill_translation_seq start with 1 increment by 50;
85
86 create sequence topic_seq start with 1 increment by 50;
87
88 create sequence topic_translation_seq start with 1 increment by 50;
89
90 create sequence user_bundle_seq start with 1 increment by 50;
91
92 create sequence user_learning_path_seq start with 1 increment by 50;
93
94 create sequence user_skill_seq start with 1 increment by 50;
95
96 create sequence user_skill_snapshot_seq start with 1 increment by 50;
97
98 create table _order (
99 created_at timestamp(6) not null,
100 id bigint not null,
101 status varchar(255) not null check (status in ('PENDING','IN_PROGRESS','COMPLETED','CANCELLED')),
102 primary key (id)
103 );
104
105 create table _user (
106 deleted boolean not null,
107 points integer,
108 profile_complete boolean not null,
109 used_free_consultation boolean not null,
110 verified boolean not null,
111 created_at timestamp(6) not null,
112 id bigint not null,
113 updated_at timestamp(6) not null,
114 company_size varchar(255) check (company_size in ('FREELANCE','MICRO','SMALL','MEDIUM','MID_MARKET','ENTERPRISE','OTHER')),
115 email varchar(255) not null,
116 login_provider varchar(255) not null check (login_provider in ('LOCAL','GOOGLE')),
117 name varchar(255),
118 password_hash varchar(255) not null,
119 work_position varchar(255),
120 primary key (id)
121 );
122
123 create table admin (
124 id bigint not null,
125 email varchar(255) not null,
126 login_provider varchar(255) not null check (login_provider in ('LOCAL','GOOGLE')),
127 name varchar(255),
128 password_hash varchar(255) not null,
129 primary key (id)
130 );
131
132 create table bundle (
133 active boolean not null,
134 base_price numeric(38,2) not null,
135 discount_amount numeric(38,2) not null,
136 discount_percentage numeric(38,2) not null,
137 created_at timestamp(6) not null,
138 deactivated_at timestamp(6),
139 id bigint not null,
140 updated_at timestamp(6) not null,
141 image_url varchar(255) not null,
142 slug varchar(255) not null,
143 type varchar(255) not null check (type in ('SYSTEM_GENERATED','CURATED','PERSONALIZED')),
144 primary key (id)
145 );
146
147 create table bundle_course (
148 bundle_id bigint not null,
149 course_id bigint not null
150 );
151
152 create table bundle_translation (
153 bundle_id bigint not null,
154 created_at timestamp(6) not null,
155 id bigint not null,
156 language_id bigint not null,
157 description varchar(255) not null,
158 title varchar(255) not null,
159 primary key (id)
160 );
161
162 create table certificate (
163 issue_date date not null,
164 enrollment_id bigint not null unique,
165 id bigint not null,
166 user_id bigint not null,
167 certificate_number varchar(255) not null,
168 certificate_url varchar(255) not null,
169 primary key (id)
170 );
171
172 create table course (
173 duration_minutes integer not null,
174 id bigint not null,
175 color varchar(255),
176 difficulty varchar(255) not null check (difficulty in ('BEGINNER','INTERMEDIATE','ADVANCED','EXPERT')),
177 image_url text not null,
178 primary key (id)
179 );
180
181 create table course_skill (
182 course_id bigint not null,
183 skill_id bigint not null
184 );
185
186 create table course_topic (
187 course_id bigint not null,
188 topic_id bigint not null
189 );
190
191 create table course_activity_event (
192 course_id bigint not null,
193 id bigint not null,
194 timestamp timestamp(6) not null,
195 user_id bigint not null,
196 event_type varchar(255) not null check (event_type in ('COURSE_VIEWED','COURSE_ENROLLED','COURSE_STARTED','COURSE_COMPLETED','COURSE_ABANDONED','LESSON_STARTED','LESSON_COMPLETED','MODULE_COMPLETED','QUIZ_ATTEMPTED','QUIZ_PASSED','QUIZ_FAILED','VIDEO_WATCHED','RESOURCE_DOWNLOADED','EXERCISE_SUBMITTED','DISCUSSION_PARTICIPATED','COURSE_WISHLISTED','COURSE_SHARED','CERTIFICATE_DOWNLOADED','COURSE_REVIEWED','COURSE_UNENROLLED','LESSON_SKIPPED')),
197 primary key (id)
198 );
199
200 create table course_lecture (
201 duration_minutes integer not null,
202 position integer not null,
203 course_module_id bigint not null,
204 id bigint not null,
205 content_type varchar(255) not null check (content_type in ('VIDEO','TEXT','FILE','QUIZ','TOOL')),
206 primary key (id)
207 );
208
209 create table course_lecture_translation (
210 course_lecture_id bigint not null,
211 created_at timestamp(6) not null,
212 id bigint not null,
213 language_id bigint not null,
214 content_file_name text,
215 content_text text,
216 description text not null,
217 title varchar(255) not null,
218 primary key (id)
219 );
220
221 create table course_module (
222 position integer not null,
223 course_version_id bigint not null,
224 id bigint not null,
225 primary key (id)
226 );
227
228 create table course_module_translation (
229 course_module_id bigint not null,
230 created_at timestamp(6) not null,
231 id bigint not null,
232 language_id bigint not null,
233 title varchar(255),
234 primary key (id)
235 );
236
237 create table course_price (
238 active boolean not null,
239 amount numeric(38,2) not null,
240 discount_amount numeric(38,2) not null,
241 discount_percentage numeric(38,2) not null,
242 discounted boolean not null,
243 course_id bigint not null,
244 created_at timestamp(6) not null,
245 id bigint not null,
246 primary key (id)
247 );
248
249 create table course_translation (
250 course_id bigint not null,
251 created_at timestamp(6) not null,
252 id bigint not null,
253 language_id bigint not null,
254 description text not null,
255 description_long text not null,
256 description_short varchar(255) not null,
257 title varchar(255) not null,
258 title_short varchar(255) not null,
259 primary key (id)
260 );
261
262 create table course_translation_what_will_be_learned (
263 course_translation_id bigint not null,
264 what_will_be_learned text
265 );
266
267 create table course_version (
268 active boolean not null,
269 creation_date date not null,
270 version_number integer not null,
271 course_id bigint not null,
272 id bigint not null,
273 primary key (id)
274 );
275
276 create table curated_bundle (
277 bundle_id bigint not null unique,
278 id bigint not null,
279 primary key (id)
280 );
281
282 create table curated_learning_path (
283 id bigint not null,
284 learning_path_id bigint not null unique,
285 primary key (id)
286 );
287
288 create table enrollment (
289 activation_date date,
290 completion_date date,
291 enrollment_date date not null,
292 on_trial boolean not null,
293 purchase_date date,
294 course_version_id bigint not null,
295 id bigint not null,
296 updated_at timestamp(6) not null,
297 user_id bigint not null,
298 enrollment_status varchar(255) not null check (enrollment_status in ('PENDING','ACTIVE','COMPLETED')),
299 enrollment_type varchar(255) not null check (enrollment_type in ('INDIVIDUAL','BUNDLE','LEARNING_PATH')),
300 primary key (id)
301 );
302
303 create table expert (
304 id bigint not null,
305 email varchar(255) not null,
306 login_provider varchar(255) not null check (login_provider in ('LOCAL','GOOGLE')),
307 name varchar(255),
308 password_hash varchar(255) not null,
309 primary key (id)
310 );
311
312 create table expert_course (
313 course_id bigint not null,
314 expert_id bigint not null
315 );
316
317 create table expert_curated_bundle (
318 curated_bundle_id bigint not null,
319 expert_id bigint not null
320 );
321
322 create table expert_curated_learning_path (
323 curated_learning_path_id bigint not null,
324 expert_id bigint not null
325 );
326
327 create table language (
328 language_code smallint not null check (language_code between 0 and 1),
329 id bigint not null,
330 name varchar(255) not null,
331 native_name varchar(255) not null,
332 primary key (id)
333 );
334
335 create table learning_path (
336 active boolean not null,
337 base_price numeric(38,2) not null,
338 discount_amount numeric(38,2) not null,
339 discount_percentage numeric(38,2) not null,
340 discounted boolean not null,
341 estimated_duration_hours integer not null,
342 created_at timestamp(6) not null,
343 deactivated_at timestamp(6),
344 id bigint not null,
345 difficulty varchar(255) not null check (difficulty in ('BEGINNER','INTERMEDIATE','ADVANCED','EXPERT')),
346 image_url varchar(255) not null,
347 slug varchar(255) not null,
348 type varchar(255) not null check (type in ('SYSTEM_GENERATED','CURATED','PERSONALIZED')),
349 primary key (id)
350 );
351
352 create table learning_path_course (
353 sequence_order integer not null,
354 course_id bigint not null,
355 id bigint not null,
356 learning_path_id bigint not null,
357 primary key (id)
358 );
359
360 create table learning_path_translation (
361 created_at timestamp(6) not null,
362 id bigint not null,
363 language_id bigint not null,
364 learning_path_id bigint not null,
365 description varchar(255) not null,
366 title varchar(255) not null,
367 primary key (id)
368 );
369
370 create table learning_path_translation_learning_outcomes (
371 learning_path_translation_id bigint not null,
372 learning_outcomes text
373 );
374
375 create table lecture_progress (
376 completed boolean not null,
377 completed_at timestamp(6) not null,
378 course_lecture_id bigint not null,
379 enrollment_id bigint not null,
380 id bigint not null,
381 primary key (id)
382 );
383
384 create table meeting_email_reminder (
385 sent boolean not null,
386 created_at timestamp(6) not null,
387 id bigint not null,
388 meeting_at timestamp(6) not null,
389 scheduled_at timestamp(6) not null,
390 updated_at timestamp(6) not null,
391 user_id bigint not null,
392 meeting_link TEXT not null,
393 status varchar(255) not null check (status in ('PENDING','SENT','FAILED')),
394 primary key (id)
395 );
396
397 create table order_details (
398 discount_amount numeric(38,2) not null,
399 discount_percentage numeric(38,2) not null,
400 price numeric(38,2) not null,
401 course_id bigint not null,
402 created_at timestamp(6) not null,
403 enrollment_id bigint not null unique,
404 id bigint not null,
405 order_id bigint not null,
406 primary key (id)
407 );
408
409 create table payment (
410 amount float(53) not null,
411 date date not null,
412 id bigint not null,
413 order_id bigint not null unique,
414 method varchar(255) not null check (method in ('CARD','PAYPAL','CASYS')),
415 status varchar(255) not null check (status in ('PENDING','COMPLETED','FAILED','REFUNDED')),
416 primary key (id)
417 );
418
419 create table personalized_bundle (
420 active boolean not null,
421 added_discount_amount numeric(38,2) not null,
422 added_discount_percent numeric(38,2) not null,
423 discounted boolean not null,
424 bundle_id bigint not null,
425 created_at timestamp(6) not null,
426 expires_at timestamp(6) not null,
427 id bigint not null,
428 source_bundle_id bigint,
429 user_id bigint not null,
430 generated_reason varchar(255) not null check (generated_reason in ('SKILL_GAP_DETECTED','CAREER_ADVANCEMENT','ROLE_RELEVANT_SKILL','COURSE_ALREADY_ENROLLED')),
431 type varchar(255) not null check (type in ('SYSTEM_RECOMMENDATION','ADJUSTED_BUNDLE')),
432 primary key (id)
433 );
434
435 create table personalized_learning_path (
436 active boolean not null,
437 added_discount_amount numeric(38,2) not null,
438 added_discount_percent numeric(38,2) not null,
439 discounted boolean not null,
440 created_at timestamp(6) not null,
441 expires_at timestamp(6) not null,
442 id bigint not null,
443 learning_path_id bigint not null,
444 source_learning_path_id bigint,
445 user_id bigint not null,
446 generated_reason varchar(255) not null check (generated_reason in ('SKILL_GAP_DETECTED','CAREER_ADVANCEMENT','ROLE_RELEVANT_SKILL','COURSE_ALREADY_ENROLLED')),
447 type varchar(255) not null check (type in ('SYSTEM_RECOMMENDATION','ADJUSTED_LEARNING_PATH')),
448 primary key (id)
449 );
450
451 create table quiz (
452 active boolean not null,
453 passing_score integer not null,
454 randomized boolean not null,
455 course_module_id bigint unique,
456 course_version_id bigint unique,
457 created_at timestamp(6) not null,
458 id bigint not null,
459 type varchar(255) not null check (type in ('PRE_DIAGNOSTIC','CHECKPOINT','FINAL')),
460 primary key (id)
461 );
462
463 create table quiz_attempt_answer_selected_options (
464 quiz_answer_option_id bigint not null,
465 quiz_attempt_answer_id bigint not null
466 );
467
468 create table quiz_answer_option (
469 correct boolean not null,
470 id bigint not null,
471 quiz_question_id bigint not null,
472 primary key (id)
473 );
474
475 create table quiz_answer_option_translation (
476 created_at timestamp(6) not null,
477 id bigint not null,
478 language_id bigint not null,
479 quiz_answer_option_id bigint not null,
480 answer_text TEXT not null,
481 explanation varchar(255) not null,
482 primary key (id)
483 );
484
485 create table quiz_attempt (
486 attempt_number integer not null,
487 earned_points integer not null,
488 passed boolean not null,
489 score integer not null,
490 total_points integer not null,
491 completed_at timestamp(6) not null,
492 enrollment_id bigint not null,
493 id bigint not null,
494 quiz_id bigint not null,
495 started_at timestamp(6) not null,
496 status varchar(255) not null check (status in ('IN_PROGRESS','PASSED','FAILED','ABANDONED')),
497 primary key (id)
498 );
499
500 create table quiz_attempt_answer (
501 correct boolean not null,
502 id bigint not null,
503 quiz_attempt_id bigint not null,
504 quiz_question_id bigint not null,
505 primary key (id)
506 );
507
508 create table quiz_question (
509 points integer not null,
510 position integer not null,
511 type smallint not null check (type between 0 and 2),
512 id bigint not null,
513 quiz_id bigint not null,
514 primary key (id)
515 );
516
517 create table quiz_question_skill (
518 proficiency smallint check (proficiency between 0 and 3),
519 weight integer,
520 id bigint not null,
521 quiz_question_id bigint not null,
522 skill_id bigint not null,
523 primary key (id)
524 );
525
526 create table quiz_question_translation (
527 created_at timestamp(6) not null,
528 id bigint not null,
529 language_id bigint not null,
530 quiz_question_id bigint not null,
531 question_text TEXT not null,
532 scenario TEXT,
533 primary key (id)
534 );
535
536 create table quiz_translation (
537 created_at timestamp(6),
538 id bigint not null,
539 language_id bigint not null,
540 quiz_id bigint not null,
541 description TEXT not null,
542 title varchar(255) not null,
543 primary key (id)
544 );
545
546 create table related_course (
547 similarity_score numeric(38,2),
548 calculated_at timestamp(6),
549 course_id bigint not null,
550 id bigint not null,
551 related_course_id bigint not null,
552 primary key (id)
553 );
554
555 create table review (
556 date date not null,
557 rating integer not null,
558 enrollment_id bigint unique,
559 id bigint not null,
560 comment varchar(255),
561 primary key (id)
562 );
563
564 create table skill (
565 show_in_radar boolean not null,
566 id bigint not null,
567 slug varchar(255) not null unique,
568 primary key (id)
569 );
570
571 create table skill_translation (
572 created_at timestamp(6) not null,
573 id bigint not null,
574 language_id bigint not null,
575 skill_id bigint not null,
576 description varchar(255) not null,
577 name varchar(255) not null,
578 primary key (id)
579 );
580
581 create table topic (
582 id bigint not null,
583 slug varchar(255) not null unique,
584 primary key (id)
585 );
586
587 create table topic_translation (
588 created_at timestamp(6) not null,
589 id bigint not null,
590 language_id bigint not null,
591 topic_id bigint not null,
592 description varchar(255) not null,
593 name varchar(255) not null,
594 primary key (id)
595 );
596
597 create table user_favorite_course (
598 course_id bigint not null,
599 user_id bigint not null
600 );
601
602 create table user_topic (
603 topic_id bigint not null,
604 user_id bigint not null
605 );
606
607 create table user_bundle (
608 acquired_date date not null,
609 bundle_id bigint not null,
610 id bigint not null,
611 user_id bigint not null,
612 primary key (id)
613 );
614
615 create table user_learning_path (
616 acquired_date date not null,
617 completed_date date,
618 progress_percentage integer not null,
619 id bigint not null,
620 learning_path_id bigint not null,
621 updated_at timestamp(6) not null,
622 user_id bigint not null,
623 status varchar(255) not null check (status in ('NOT_STARTED','IN_PROGRESS','COMPLETED')),
624 primary key (id)
625 );
626
627 create table user_skill (
628 proficiency_score integer not null,
629 verified boolean not null,
630 created_at timestamp(6) not null,
631 enrollment_id bigint not null,
632 id bigint not null,
633 skill_id bigint not null,
634 updated_at timestamp(6) not null,
635 user_id bigint not null,
636 proficiency varchar(255) not null check (proficiency in ('BEGINNER','INTERMEDIATE','ADVANCED','EXPERT')),
637 primary key (id)
638 );
639
640 create table user_skill_snapshot (
641 new_proficiency_score integer not null,
642 proficiency_score_at_time integer not null,
643 created_at timestamp(6) not null,
644 enrollment_id bigint not null,
645 id bigint not null,
646 quiz_attempt_id bigint not null,
647 user_skill_id bigint not null,
648 new_proficiency varchar(255) not null check (new_proficiency in ('BEGINNER','INTERMEDIATE','ADVANCED','EXPERT')),
649 proficiency_at_time varchar(255) not null check (proficiency_at_time in ('BEGINNER','INTERMEDIATE','ADVANCED','EXPERT')),
650 primary key (id)
651 );
652
653 create table verification_token (
654 created_at timestamp(6) with time zone not null,
655 expires_at timestamp(6) with time zone not null,
656 user_id bigint not null unique,
657 token uuid not null,
658 primary key (token)
659 );
660
661 alter table if exists bundle_course
662 add constraint FKdo0xhpiebtit8dcqcxp91wc78
663 foreign key (course_id)
664 references course;
665
666 alter table if exists bundle_course
667 add constraint FK7gfrx8wdbn1kl5opvv0lprnsg
668 foreign key (bundle_id)
669 references bundle;
670
671 alter table if exists bundle_translation
672 add constraint FKsgh1lwfc5xk5f6hnqacb610gh
673 foreign key (bundle_id)
674 references bundle;
675
676 alter table if exists bundle_translation
677 add constraint FKmghxjh3mk0f6toe37g1mbxpvw
678 foreign key (language_id)
679 references language;
680
681 alter table if exists certificate
682 add constraint FK6ahwata2qxlvb8e3fe0qtseq1
683 foreign key (enrollment_id)
684 references enrollment;
685
686 alter table if exists certificate
687 add constraint FKk01mc5gvmwis2leepuntymwek
688 foreign key (user_id)
689 references _user;
690
691 alter table if exists course_skill
692 add constraint FKdq4boqb20geguit45rgr1r33v
693 foreign key (skill_id)
694 references skill;
695
696 alter table if exists course_skill
697 add constraint FKn17ep7229hbi0li6eobs1mi6q
698 foreign key (course_id)
699 references course;
700
701 alter table if exists course_topic
702 add constraint FKpmlbmev283ud50kxgvmyjcbhj
703 foreign key (topic_id)
704 references topic;
705
706 alter table if exists course_topic
707 add constraint FK6esfb41t5ja5jp8p49uv72x9d
708 foreign key (course_id)
709 references course;
710
711 alter table if exists course_activity_event
712 add constraint FKl0jx91qej21fg8kddkbxyceca
713 foreign key (course_id)
714 references course;
715
716 alter table if exists course_activity_event
717 add constraint FKsti6o99mr9vn1epoinlpn3v1b
718 foreign key (user_id)
719 references _user;
720
721 alter table if exists course_lecture
722 add constraint FK4jkngg76jhg924w4ecest5qhh
723 foreign key (course_module_id)
724 references course_module;
725
726 alter table if exists course_lecture_translation
727 add constraint FKlo1l7xrk68w58ko5ht81aqoq5
728 foreign key (course_lecture_id)
729 references course_lecture;
730
731 alter table if exists course_lecture_translation
732 add constraint FKj047131hx9cktrm1s0k1np84x
733 foreign key (language_id)
734 references language;
735
736 alter table if exists course_module
737 add constraint FKaqw6q4ekvbyb71xbxf9qo06id
738 foreign key (course_version_id)
739 references course_version;
740
741 alter table if exists course_module_translation
742 add constraint FKtfwkv3tsnes007s30d2b1ufqb
743 foreign key (course_module_id)
744 references course_module;
745
746 alter table if exists course_module_translation
747 add constraint FKgwr1ag27g98rpl9eawhtbl3vd
748 foreign key (language_id)
749 references language;
750
751 alter table if exists course_price
752 add constraint FK9qy75q9hyu79mfx4i80rbd57
753 foreign key (course_id)
754 references course;
755
756 alter table if exists course_translation
757 add constraint FKo07pv1i5tntp4ovua364ifif9
758 foreign key (course_id)
759 references course;
760
761 alter table if exists course_translation
762 add constraint FK6s42mrhvqbelvfbqao9ak8qr9
763 foreign key (language_id)
764 references language;
765
766 alter table if exists course_translation_what_will_be_learned
767 add constraint FKs4hlvl9eopb5gcu3saftrodgx
768 foreign key (course_translation_id)
769 references course_translation;
770
771 alter table if exists course_version
772 add constraint FK6yglm1887hjjbrm60ll1eg2fv
773 foreign key (course_id)
774 references course;
775
776 alter table if exists curated_bundle
777 add constraint FK4atyfqgbdqjub5p6a5ems4blf
778 foreign key (bundle_id)
779 references bundle;
780
781 alter table if exists curated_learning_path
782 add constraint FK1rkmrhutbilapn9tksgrf0p4q
783 foreign key (learning_path_id)
784 references learning_path;
785
786 alter table if exists enrollment
787 add constraint FKqch2vm3goe0xq8i4b2p0s6n5c
788 foreign key (course_version_id)
789 references course_version;
790
791 alter table if exists enrollment
792 add constraint FKk2q6td98gy1kh54uxtompibte
793 foreign key (user_id)
794 references _user;
795
796 alter table if exists expert_course
797 add constraint FKdi9swk9y35h363h9arfi8cv7i
798 foreign key (course_id)
799 references course;
800
801 alter table if exists expert_course
802 add constraint FKl8f98fsvl2rsrcfyehpytorjm
803 foreign key (expert_id)
804 references expert;
805
806 alter table if exists expert_curated_bundle
807 add constraint FKcl731nyfiesam1hhblgu52lkx
808 foreign key (curated_bundle_id)
809 references curated_bundle;
810
811 alter table if exists expert_curated_bundle
812 add constraint FKktqhmeu183njbob7sjban6e9h
813 foreign key (expert_id)
814 references expert;
815
816 alter table if exists expert_curated_learning_path
817 add constraint FK2jc4fkqvn2o8kc7idkbi656bu
818 foreign key (curated_learning_path_id)
819 references curated_learning_path;
820
821 alter table if exists expert_curated_learning_path
822 add constraint FK8awl7vwwnp8k4en34o5sb0dip
823 foreign key (expert_id)
824 references expert;
825
826 alter table if exists learning_path_course
827 add constraint FKishnjvramgwwa7thrjou3kddp
828 foreign key (course_id)
829 references course;
830
831 alter table if exists learning_path_course
832 add constraint FKgklotfyjlrc0ydbfnu2ff78d4
833 foreign key (learning_path_id)
834 references learning_path;
835
836 alter table if exists learning_path_translation
837 add constraint FKt1da5n6j3kxyjd9585w598r18
838 foreign key (language_id)
839 references language;
840
841 alter table if exists learning_path_translation
842 add constraint FKf9q56u6d1qm4clatp9vcp5g1u
843 foreign key (learning_path_id)
844 references learning_path;
845
846 alter table if exists learning_path_translation_learning_outcomes
847 add constraint FK5ysnfvqfk8bv24scoftdai4ed
848 foreign key (learning_path_translation_id)
849 references learning_path_translation;
850
851 alter table if exists lecture_progress
852 add constraint FKonh9tp6oswh0r969va5k29qcp
853 foreign key (course_lecture_id)
854 references course_lecture;
855
856 alter table if exists lecture_progress
857 add constraint FKg66j5hw5xj3xpb2aei7n9u8h4
858 foreign key (enrollment_id)
859 references enrollment;
860
861 alter table if exists meeting_email_reminder
862 add constraint FKy8jy72yp609y7oynv2jt34wc
863 foreign key (user_id)
864 references _user;
865
866 alter table if exists order_details
867 add constraint FKkb349a35bgtcmvcchhsjil24g
868 foreign key (course_id)
869 references course;
870
871 alter table if exists order_details
872 add constraint FKirqg49mevvtyher2f1vrmog63
873 foreign key (enrollment_id)
874 references enrollment;
875
876 alter table if exists order_details
877 add constraint FK7xtsljbo390gc608yxxdrwi5r
878 foreign key (order_id)
879 references _order;
880
881 alter table if exists payment
882 add constraint FKp12cpy6idihw3gyo3sv7pfcw2
883 foreign key (order_id)
884 references _order;
885
886 alter table if exists personalized_bundle
887 add constraint FKg1kly5ojlcp9cc2l40rxpw4up
888 foreign key (bundle_id)
889 references bundle;
890
891 alter table if exists personalized_bundle
892 add constraint FKpu1xid370ofgyo71a8rgi087v
893 foreign key (source_bundle_id)
894 references curated_bundle;
895
896 alter table if exists personalized_bundle
897 add constraint FK6t67fgumndnw2aswgm8iy3ql
898 foreign key (user_id)
899 references _user;
900
901 alter table if exists personalized_learning_path
902 add constraint FK26yby03yywv3qj3mlffx60swg
903 foreign key (learning_path_id)
904 references learning_path;
905
906 alter table if exists personalized_learning_path
907 add constraint FKoj7jamgtd310vffare41id3jl
908 foreign key (source_learning_path_id)
909 references curated_learning_path;
910
911 alter table if exists personalized_learning_path
912 add constraint FKn3ej0qye221430t7odddlhjir
913 foreign key (user_id)
914 references _user;
915
916 alter table if exists quiz
917 add constraint FKh1oxnsy9mlbm9327assy73554
918 foreign key (course_module_id)
919 references course_module;
920
921 alter table if exists quiz
922 add constraint FK7ipimjgupvu0n9069efe8j3n9
923 foreign key (course_version_id)
924 references course_version;
925
926 alter table if exists quiz_attempt_answer_selected_options
927 add constraint FK6qebj52a5eo2k279tek54ffia
928 foreign key (quiz_answer_option_id)
929 references quiz_answer_option;
930
931 alter table if exists quiz_attempt_answer_selected_options
932 add constraint FK4qgqoa7r29lx1f7wc2conwtrk
933 foreign key (quiz_attempt_answer_id)
934 references quiz_attempt_answer;
935
936 alter table if exists quiz_answer_option
937 add constraint FKn4qkhxiy5vbgk2bw4lmnyly0i
938 foreign key (quiz_question_id)
939 references quiz_question;
940
941 alter table if exists quiz_answer_option_translation
942 add constraint FK8b2rqcn8td0s6jyuiiv4jnann
943 foreign key (quiz_answer_option_id)
944 references quiz_answer_option;
945
946 alter table if exists quiz_answer_option_translation
947 add constraint FKo92tkgn8taqn8mltxx26oyg3x
948 foreign key (language_id)
949 references language;
950
951 alter table if exists quiz_attempt
952 add constraint FK1mfvh50tb8kir4uvilp6btaaw
953 foreign key (enrollment_id)
954 references enrollment;
955
956 alter table if exists quiz_attempt
957 add constraint FK8l6wmgul0rgeha0lp6abrp5fa
958 foreign key (quiz_id)
959 references quiz;
960
961 alter table if exists quiz_attempt_answer
962 add constraint FKkjt1vbkna2o7m6kkph3mdly51
963 foreign key (quiz_question_id)
964 references quiz_question;
965
966 alter table if exists quiz_attempt_answer
967 add constraint FK3drqtufjr375d34nehuidp1xy
968 foreign key (quiz_attempt_id)
969 references quiz_attempt;
970
971 alter table if exists quiz_question
972 add constraint FKdtynvfjgh6e7fd8l0wk37nrpc
973 foreign key (quiz_id)
974 references quiz;
975
976 alter table if exists quiz_question_skill
977 add constraint FK3yl3t40y5wpse8pnjifj86mt6
978 foreign key (quiz_question_id)
979 references quiz_question;
980
981 alter table if exists quiz_question_skill
982 add constraint FKtf69jtugu6navrve98lfkcmy7
983 foreign key (skill_id)
984 references skill;
985
986 alter table if exists quiz_question_translation
987 add constraint FKtou73sdkxkcq0hvld1t8qv5me
988 foreign key (language_id)
989 references language;
990
991 alter table if exists quiz_question_translation
992 add constraint FKnw56gk9jtbc8q80ccnk29te8v
993 foreign key (quiz_question_id)
994 references quiz_question;
995
996 alter table if exists quiz_translation
997 add constraint FKg9xfiijbskc3a4s6h9u7wkctg
998 foreign key (language_id)
999 references language;
1000
1001 alter table if exists quiz_translation
1002 add constraint FK9yadrfalpr28602fjp6exrir7
1003 foreign key (quiz_id)
1004 references quiz;
1005
1006 alter table if exists related_course
1007 add constraint FKavg12dqv92iedvowrefqve7qf
1008 foreign key (course_id)
1009 references course;
1010
1011 alter table if exists related_course
1012 add constraint FK9ndljtid903b318m3y368a8q0
1013 foreign key (related_course_id)
1014 references course;
1015
1016 alter table if exists review
1017 add constraint FKtbcjdinaby874shrxwa2by95k
1018 foreign key (enrollment_id)
1019 references enrollment;
1020
1021 alter table if exists skill_translation
1022 add constraint FK1or8evd3rtbsiqdcvafj2pj85
1023 foreign key (language_id)
1024 references language;
1025
1026 alter table if exists skill_translation
1027 add constraint FK487nr9gqeb3reepdasuccwetv
1028 foreign key (skill_id)
1029 references skill;
1030
1031 alter table if exists topic_translation
1032 add constraint FKa44hr73wwpc0ihy1e23xa7vnq
1033 foreign key (language_id)
1034 references language;
1035
1036 alter table if exists topic_translation
1037 add constraint FKnxnvsuhfxhb93jlq9352dghmm
1038 foreign key (topic_id)
1039 references topic;
1040
1041 alter table if exists user_favorite_course
1042 add constraint FKpd7kuwmi2fts1x0rnsm46ven5
1043 foreign key (course_id)
1044 references course;
1045
1046 alter table if exists user_favorite_course
1047 add constraint FKkx7btq6vl0t7c92wk101oce7b
1048 foreign key (user_id)
1049 references _user;
1050
1051 alter table if exists user_topic
1052 add constraint FKrbbt9w8w48w4pl7dv0lh3om0v
1053 foreign key (topic_id)
1054 references topic;
1055
1056 alter table if exists user_topic
1057 add constraint FKrigmw1ul2tladbkykn6p7nq9y
1058 foreign key (user_id)
1059 references _user;
1060
1061 alter table if exists user_bundle
1062 add constraint FKkgujilv0ofi6carmk8mynjc82
1063 foreign key (bundle_id)
1064 references bundle;
1065
1066 alter table if exists user_bundle
1067 add constraint FKp71mnd97q842p2muw98c496d
1068 foreign key (user_id)
1069 references _user;
1070
1071 alter table if exists user_learning_path
1072 add constraint FK1gg9vx9pf19d7bal3x6xb50uc
1073 foreign key (learning_path_id)
1074 references learning_path;
1075
1076 alter table if exists user_learning_path
1077 add constraint FKj1whqeu8rm7dddql70uh3qq93
1078 foreign key (user_id)
1079 references _user;
1080
1081 alter table if exists user_skill
1082 add constraint FKo92ghoo9sk6kemgvb6d9lpq8k
1083 foreign key (enrollment_id)
1084 references enrollment;
1085
1086 alter table if exists user_skill
1087 add constraint FKj53flyds4vknyh8llw5d7jdop
1088 foreign key (skill_id)
1089 references skill;
1090
1091 alter table if exists user_skill
1092 add constraint FKqsxejk0f9hr4jpdoygwoyn6qg
1093 foreign key (user_id)
1094 references _user;
1095
1096 alter table if exists user_skill_snapshot
1097 add constraint FKqasc7n3cyymgb3x6l7btskbab
1098 foreign key (enrollment_id)
1099 references enrollment;
1100
1101 alter table if exists user_skill_snapshot
1102 add constraint FKrkpjyrpl6c4m2r0rw43e24u5s
1103 foreign key (quiz_attempt_id)
1104 references quiz_attempt;
1105
1106 alter table if exists user_skill_snapshot
1107 add constraint FKr22wle0esupohke0m179l39tv
1108 foreign key (user_skill_id)
1109 references user_skill;
1110
1111 alter table if exists verification_token
1112 add constraint FK311qhdx7kfhq2m0utkvjs7ay8
1113 foreign key (user_id)
1114 references _user;