Skip to content

Commit ed5123f

Browse files
Merge pull request #102 from SCE-Development/better-course-info/schema
Schema for the better course info branch
2 parents cab4d03 + afb0279 commit ed5123f

9 files changed

Lines changed: 194 additions & 621 deletions
Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,20 @@ CREATE TABLE IF NOT EXISTS "courses" (
44
"title" text NOT NULL,
55
"subject" text NOT NULL,
66
"course_number" text NOT NULL,
7-
"description" text
7+
"class_number" text NOT NULL,
8+
"units" text NOT NULL,
9+
"type" text NOT NULL,
10+
"days" text NOT NULL,
11+
"time" text NOT NULL,
12+
"location" text NOT NULL,
13+
"dates" text NOT NULL,
14+
"open_seats" text NOT NULL,
15+
"description" text,
16+
"search_vector" "tsvector" GENERATED ALWAYS AS (setweight(to_tsvector('english', "courses"."subject"), 'A') ||
17+
setweight(to_tsvector('english', "courses"."course_number"), 'A') ||
18+
setweight(to_tsvector('english', "courses"."class_number"), 'B') ||
19+
setweight(to_tsvector('english', "courses"."title"), 'C') ||
20+
setweight(to_tsvector('english', "courses"."semester"), 'D')) STORED NOT NULL
821
);
922
--> statement-breakpoint
1023
CREATE TABLE IF NOT EXISTS "professors_courses" (
@@ -16,7 +29,13 @@ CREATE TABLE IF NOT EXISTS "professors_courses" (
1629
CREATE TABLE IF NOT EXISTS "professors" (
1730
"id" serial PRIMARY KEY NOT NULL,
1831
"name" text NOT NULL,
19-
"department" text NOT NULL
32+
"department" text NOT NULL,
33+
"avg_rating" real,
34+
"avg_difficulty" real,
35+
"num_ratings" integer,
36+
"would_take_again_percent" real,
37+
"search_vector" "tsvector" GENERATED ALWAYS AS (setweight(to_tsvector('english', "professors"."name"), 'A') ||
38+
setweight(to_tsvector('english', "professors"."department"), 'B')) STORED NOT NULL
2039
);
2140
--> statement-breakpoint
2241
CREATE TABLE IF NOT EXISTS "reviews" (
@@ -67,4 +86,4 @@ DO $$ BEGIN
6786
ALTER TABLE "session" ADD CONSTRAINT "session_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."user"("id") ON DELETE no action ON UPDATE no action;
6887
EXCEPTION
6988
WHEN duplicate_object THEN null;
70-
END $$;
89+
END $$;

drizzle/0001_cuddly_onslaught.sql

Lines changed: 0 additions & 19 deletions
This file was deleted.

drizzle/0002_parched_steve_rogers.sql

Lines changed: 0 additions & 1 deletion
This file was deleted.

drizzle/0003_real_brother_voodoo.sql

Lines changed: 0 additions & 6 deletions
This file was deleted.

drizzle/meta/0000_snapshot.json

Lines changed: 155 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"id": "4b155cce-3204-4ceb-b826-accc4d0a223e",
2+
"id": "e794e902-9e80-4aae-9f1b-5353952a3aac",
33
"prevId": "00000000-0000-0000-0000-000000000000",
44
"version": "7",
55
"dialect": "postgresql",
@@ -38,17 +38,78 @@
3838
"primaryKey": false,
3939
"notNull": true
4040
},
41+
"class_number": {
42+
"name": "class_number",
43+
"type": "text",
44+
"primaryKey": false,
45+
"notNull": true
46+
},
47+
"units": {
48+
"name": "units",
49+
"type": "text",
50+
"primaryKey": false,
51+
"notNull": true
52+
},
53+
"type": {
54+
"name": "type",
55+
"type": "text",
56+
"primaryKey": false,
57+
"notNull": true
58+
},
59+
"days": {
60+
"name": "days",
61+
"type": "text",
62+
"primaryKey": false,
63+
"notNull": true
64+
},
65+
"time": {
66+
"name": "time",
67+
"type": "text",
68+
"primaryKey": false,
69+
"notNull": true
70+
},
71+
"location": {
72+
"name": "location",
73+
"type": "text",
74+
"primaryKey": false,
75+
"notNull": true
76+
},
77+
"dates": {
78+
"name": "dates",
79+
"type": "text",
80+
"primaryKey": false,
81+
"notNull": true
82+
},
83+
"open_seats": {
84+
"name": "open_seats",
85+
"type": "text",
86+
"primaryKey": false,
87+
"notNull": true
88+
},
4189
"description": {
4290
"name": "description",
4391
"type": "text",
4492
"primaryKey": false,
4593
"notNull": false
94+
},
95+
"search_vector": {
96+
"name": "search_vector",
97+
"type": "tsvector",
98+
"primaryKey": false,
99+
"notNull": true,
100+
"generated": {
101+
"as": "setweight(to_tsvector('english', \"courses\".\"subject\"), 'A') ||\n setweight(to_tsvector('english', \"courses\".\"course_number\"), 'A') ||\n setweight(to_tsvector('english', \"courses\".\"class_number\"), 'B') ||\n setweight(to_tsvector('english', \"courses\".\"title\"), 'C') ||\n setweight(to_tsvector('english', \"courses\".\"semester\"), 'D')",
102+
"type": "stored"
103+
}
46104
}
47105
},
48106
"indexes": {},
49107
"foreignKeys": {},
50108
"compositePrimaryKeys": {},
51-
"uniqueConstraints": {}
109+
"uniqueConstraints": {},
110+
"policies": {},
111+
"checkConstraints": {},
112+
"isRLSEnabled": false
52113
},
53114
"public.professors_courses": {
54115
"name": "professors_courses",
@@ -73,28 +134,42 @@
73134
"name": "professors_courses_professor_id_professors_id_fk",
74135
"tableFrom": "professors_courses",
75136
"tableTo": "professors",
76-
"columnsFrom": ["professor_id"],
77-
"columnsTo": ["id"],
137+
"columnsFrom": [
138+
"professor_id"
139+
],
140+
"columnsTo": [
141+
"id"
142+
],
78143
"onDelete": "no action",
79144
"onUpdate": "no action"
80145
},
81146
"professors_courses_course_id_courses_id_fk": {
82147
"name": "professors_courses_course_id_courses_id_fk",
83148
"tableFrom": "professors_courses",
84149
"tableTo": "courses",
85-
"columnsFrom": ["course_id"],
86-
"columnsTo": ["id"],
150+
"columnsFrom": [
151+
"course_id"
152+
],
153+
"columnsTo": [
154+
"id"
155+
],
87156
"onDelete": "no action",
88157
"onUpdate": "no action"
89158
}
90159
},
91160
"compositePrimaryKeys": {
92161
"professors_courses_professor_id_course_id_pk": {
93162
"name": "professors_courses_professor_id_course_id_pk",
94-
"columns": ["professor_id", "course_id"]
163+
"columns": [
164+
"professor_id",
165+
"course_id"
166+
]
95167
}
96168
},
97-
"uniqueConstraints": {}
169+
"uniqueConstraints": {},
170+
"policies": {},
171+
"checkConstraints": {},
172+
"isRLSEnabled": false
98173
},
99174
"public.professors": {
100175
"name": "professors",
@@ -117,12 +192,49 @@
117192
"type": "text",
118193
"primaryKey": false,
119194
"notNull": true
195+
},
196+
"avg_rating": {
197+
"name": "avg_rating",
198+
"type": "real",
199+
"primaryKey": false,
200+
"notNull": false
201+
},
202+
"avg_difficulty": {
203+
"name": "avg_difficulty",
204+
"type": "real",
205+
"primaryKey": false,
206+
"notNull": false
207+
},
208+
"num_ratings": {
209+
"name": "num_ratings",
210+
"type": "integer",
211+
"primaryKey": false,
212+
"notNull": false
213+
},
214+
"would_take_again_percent": {
215+
"name": "would_take_again_percent",
216+
"type": "real",
217+
"primaryKey": false,
218+
"notNull": false
219+
},
220+
"search_vector": {
221+
"name": "search_vector",
222+
"type": "tsvector",
223+
"primaryKey": false,
224+
"notNull": true,
225+
"generated": {
226+
"as": "setweight(to_tsvector('english', \"professors\".\"name\"), 'A') ||\n setweight(to_tsvector('english', \"professors\".\"department\"), 'B')",
227+
"type": "stored"
228+
}
120229
}
121230
},
122231
"indexes": {},
123232
"foreignKeys": {},
124233
"compositePrimaryKeys": {},
125-
"uniqueConstraints": {}
234+
"uniqueConstraints": {},
235+
"policies": {},
236+
"checkConstraints": {},
237+
"isRLSEnabled": false
126238
},
127239
"public.reviews": {
128240
"name": "reviews",
@@ -165,23 +277,34 @@
165277
"name": "reviews_course_id_courses_id_fk",
166278
"tableFrom": "reviews",
167279
"tableTo": "courses",
168-
"columnsFrom": ["course_id"],
169-
"columnsTo": ["id"],
280+
"columnsFrom": [
281+
"course_id"
282+
],
283+
"columnsTo": [
284+
"id"
285+
],
170286
"onDelete": "no action",
171287
"onUpdate": "no action"
172288
},
173289
"reviews_professor_id_professors_id_fk": {
174290
"name": "reviews_professor_id_professors_id_fk",
175291
"tableFrom": "reviews",
176292
"tableTo": "professors",
177-
"columnsFrom": ["professor_id"],
178-
"columnsTo": ["id"],
293+
"columnsFrom": [
294+
"professor_id"
295+
],
296+
"columnsTo": [
297+
"id"
298+
],
179299
"onDelete": "no action",
180300
"onUpdate": "no action"
181301
}
182302
},
183303
"compositePrimaryKeys": {},
184-
"uniqueConstraints": {}
304+
"uniqueConstraints": {},
305+
"policies": {},
306+
"checkConstraints": {},
307+
"isRLSEnabled": false
185308
},
186309
"public.session": {
187310
"name": "session",
@@ -212,14 +335,21 @@
212335
"name": "session_user_id_user_id_fk",
213336
"tableFrom": "session",
214337
"tableTo": "user",
215-
"columnsFrom": ["user_id"],
216-
"columnsTo": ["id"],
338+
"columnsFrom": [
339+
"user_id"
340+
],
341+
"columnsTo": [
342+
"id"
343+
],
217344
"onDelete": "no action",
218345
"onUpdate": "no action"
219346
}
220347
},
221348
"compositePrimaryKeys": {},
222-
"uniqueConstraints": {}
349+
"uniqueConstraints": {},
350+
"policies": {},
351+
"checkConstraints": {},
352+
"isRLSEnabled": false
223353
},
224354
"public.user": {
225355
"name": "user",
@@ -247,15 +377,21 @@
247377
"indexes": {},
248378
"foreignKeys": {},
249379
"compositePrimaryKeys": {},
250-
"uniqueConstraints": {}
380+
"uniqueConstraints": {},
381+
"policies": {},
382+
"checkConstraints": {},
383+
"isRLSEnabled": false
251384
}
252385
},
253386
"enums": {},
254387
"schemas": {},
255388
"sequences": {},
389+
"roles": {},
390+
"policies": {},
391+
"views": {},
256392
"_meta": {
257393
"columns": {},
258394
"schemas": {},
259395
"tables": {}
260396
}
261-
}
397+
}

0 commit comments

Comments
 (0)