@@ -22,27 +22,20 @@ export const section = pgTable(
2222 . primaryKey ( ) ,
2323
2424 // "CS" or "CE", short and indexable
25- prefix : varchar ( 'prefix' , { length : 4 } )
26- . notNull ( ) ,
25+ prefix : varchar ( 'prefix' , { length : 4 } ) . notNull ( ) ,
2726
2827 // Course number like 1200
29- number : varchar ( 'number' , { length : 4 } )
30- . notNull ( ) ,
28+ number : varchar ( 'number' , { length : 4 } ) . notNull ( ) ,
3129
3230 // Section code like "001"
33- sectionCode : varchar ( 'section_code' , { length : 3 } )
34- . notNull ( ) ,
31+ sectionCode : varchar ( 'section_code' , { length : 3 } ) . notNull ( ) ,
3532
3633 // Semester split into term + year for better filtering
37- term : termEnum ( 'term' )
38- . notNull ( ) ,
39- year : smallint ( 'year' )
40- . notNull ( ) ,
34+ term : termEnum ( 'term' ) . notNull ( ) ,
35+ year : smallint ( 'year' ) . notNull ( ) ,
4136
4237 professor : text ( 'professor' ) ,
43- numberOfNotes : integer ( 'number_of_notes' )
44- . notNull ( )
45- . default ( 0 ) ,
38+ numberOfNotes : integer ( 'number_of_notes' ) . notNull ( ) . default ( 0 ) ,
4639
4740 // Not required, but good practice usually
4841 createdAt : timestamp ( 'created_at' , { withTimezone : true } )
@@ -52,14 +45,20 @@ export const section = pgTable(
5245 . notNull ( )
5346 . defaultNow ( ) ,
5447 } ,
55- ( t ) => ( [
56- uniqueIndex ( 'section_unique_idx' ) . on ( t . prefix , t . number , t . sectionCode , t . term , t . year ) ,
48+ ( t ) => [
49+ uniqueIndex ( 'section_unique_idx' ) . on (
50+ t . prefix ,
51+ t . number ,
52+ t . sectionCode ,
53+ t . term ,
54+ t . year ,
55+ ) ,
5756 index ( 'section_by_course_idx' ) . on ( t . prefix , t . number ) ,
5857 index ( 'section_by_professor_idx' ) . on ( t . professor ) ,
5958 index ( 'section_by_semester_idx' ) . on ( t . term , t . year ) ,
60- ] ) ,
59+ ] ,
6160) ;
6261
6362export const sectionRelations = relations ( section , ( { many } ) => ( {
6463 files : many ( file ) ,
65- } ) ) ;
64+ } ) ) ;
0 commit comments