11import { relations } from 'drizzle-orm' ;
22import { pgTable , uniqueIndex } from 'drizzle-orm/pg-core' ;
33
4- import { departments , persons , sections } from '.' ;
4+ import { deans , departments , persons , sections } from '.' ;
55
66export const staff = pgTable (
77 'staff' ,
@@ -12,9 +12,13 @@ export const staff = pgTable(
1212 . references ( ( ) => persons . id ) ,
1313 employeeId : t . varchar ( { length : 8 } ) . notNull ( ) ,
1414 personalEmail : t . varchar ( { length : 256 } ) ,
15- workingSectionId : t . smallint ( ) . references ( ( ) => sections . id ) ,
1615 designation : t . varchar ( { length : 64 } ) . notNull ( ) ,
16+ workingOfficeType : t . varchar ( {
17+ enum : [ 'department' , 'section' , 'deans' ] ,
18+ } ) ,
1719 workingDepartmentId : t . smallint ( ) . references ( ( ) => departments . id ) ,
20+ workingSectionId : t . smallint ( ) . references ( ( ) => sections . id ) ,
21+ workingDeanOfficeId : t . smallint ( ) . references ( ( ) => deans . id ) ,
1822 } ) ,
1923 ( table ) => [ uniqueIndex ( 'staff_employee_id_idx' ) . on ( table . employeeId ) ]
2024) ;
@@ -32,4 +36,8 @@ export const staffRelations = relations(staff, ({ one }) => ({
3236 fields : [ staff . workingSectionId ] ,
3337 references : [ sections . id ] ,
3438 } ) ,
39+ deans : one ( deans , {
40+ fields : [ staff . workingDeanOfficeId ] ,
41+ references : [ deans . id ] ,
42+ } ) ,
3543} ) ) ;
0 commit comments