@@ -26,7 +26,7 @@ export const faculty = pgTable(
2626 id : integer ( 'id' )
2727 . primaryKey ( )
2828 . references ( ( ) => persons . id ) ,
29- employeeId : varchar ( 'employee_id' , { length : 8 } ) . notNull ( ) ,
29+ employeeId : varchar ( 'employee_id' , { length : 8 } ) . unique ( ) . notNull ( ) ,
3030 officeAddress : varchar ( 'college_address' , { length : 16 } ) . notNull ( ) ,
3131 designation : varchar ( 'designation' , {
3232 enum : [
@@ -55,12 +55,12 @@ export const faculty = pgTable(
5555
5656// Qualifications Table
5757export const qualifications = pgTable ( 'qualifications' , {
58- id : integer ( 'id' ) . primaryKey ( ) ,
59- facultyId : integer ( 'faculty_id' )
60- . references ( ( ) => faculty . id )
58+ id : serial ( 'id' ) . primaryKey ( ) ,
59+ employeeId : varchar ( 'employee_id' , { length : 8 } )
60+ . references ( ( ) => faculty . employeeId )
6161 . notNull ( ) ,
6262 title : text ( 'title' ) . notNull ( ) ,
63- about : text ( 'about' ) . notNull ( ) ,
63+ field : text ( 'about' ) . notNull ( ) ,
6464 location : text ( 'location' ) . notNull ( ) ,
6565 startDate : date ( 'start_date' ) . notNull ( ) ,
6666 endDate : date ( 'end_date' ) ,
@@ -69,21 +69,21 @@ export const qualifications = pgTable('qualifications', {
6969// Experience Table
7070export const experience = pgTable ( 'experience' , {
7171 id : serial ( 'id' ) . primaryKey ( ) ,
72- facultyId : integer ( 'faculty_id' )
73- . references ( ( ) => faculty . id )
72+ employeeId : varchar ( 'employee_id' , { length : 8 } )
73+ . references ( ( ) => faculty . employeeId )
7474 . notNull ( ) ,
7575 title : text ( 'title' ) . notNull ( ) ,
76- description : text ( 'description ' ) . notNull ( ) ,
77- place : text ( 'place ' ) . notNull ( ) ,
76+ field : text ( 'field ' ) . notNull ( ) ,
77+ location : text ( 'location ' ) . notNull ( ) ,
7878 startDate : date ( 'start_date' ) . notNull ( ) ,
79- endDate : date ( 'end_date' ) . notNull ( ) ,
79+ endDate : date ( 'end_date' ) ,
8080} ) ;
8181
8282// Projects Table
8383export const projects = pgTable ( 'projects' , {
8484 id : serial ( 'id' ) . primaryKey ( ) ,
85- facultyId : integer ( 'faculty_id' )
86- . references ( ( ) => faculty . id )
85+ employeeId : varchar ( 'employee_id' , { length : 8 } )
86+ . references ( ( ) => faculty . employeeId )
8787 . notNull ( ) ,
8888 title : text ( 'title' ) . notNull ( ) ,
8989 field : text ( 'field' ) . notNull ( ) ,
@@ -98,24 +98,24 @@ export const projects = pgTable('projects', {
9898// Continuing Education Table
9999export const continuingEducation = pgTable ( 'continuing_education' , {
100100 id : serial ( 'id' ) . primaryKey ( ) ,
101- facultyId : integer ( 'faculty_id' )
102- . references ( ( ) => faculty . id )
101+ employeeId : varchar ( 'employee_id' , { length : 8 } )
102+ . references ( ( ) => faculty . employeeId )
103103 . notNull ( ) ,
104104 title : text ( 'title' ) . notNull ( ) ,
105- field : text ( 'field ' ) . notNull ( ) ,
105+ type : text ( 'type ' ) . notNull ( ) ,
106106 role : text ( 'role' ) . notNull ( ) ,
107107 startDate : date ( 'start_date' ) . notNull ( ) ,
108108 endDate : date ( 'end_date' ) . notNull ( ) ,
109109} ) ;
110110
111111// Publications Table
112112export const publications = pgTable ( 'publications' , {
113- id : integer ( 'id' ) . primaryKey ( ) ,
114- facultyId : integer ( 'faculty_id' )
115- . references ( ( ) => faculty . id )
113+ id : serial ( 'id' ) . primaryKey ( ) ,
114+ employeeId : varchar ( 'employee_id' , { length : 8 } )
115+ . references ( ( ) => faculty . employeeId )
116116 . notNull ( ) ,
117117 title : text ( 'title' ) . notNull ( ) ,
118- field : text ( 'field ' ) . notNull ( ) ,
118+ details : text ( 'details ' ) . notNull ( ) ,
119119 people : text ( 'people' ) . notNull ( ) ,
120120 date : date ( 'date' ) . notNull ( ) ,
121121 tag : varchar ( 'tag' , {
@@ -125,7 +125,7 @@ export const publications = pgTable('publications', {
125125
126126// // Research Scholars Table
127127// export const researchScholars = pgTable('research_scholars', {
128- // id: integer ('id').primaryKey(),
128+ // id: serial ('id').primaryKey(),
129129// facultyId: integer('faculty_id')
130130// .references(() => faculty.id)
131131// .notNull(),
@@ -138,21 +138,21 @@ export const publications = pgTable('publications', {
138138
139139// Awards and Honors Table
140140export const awardsAndHonors = pgTable ( 'awards_and_honors' , {
141- id : integer ( 'id' ) . primaryKey ( ) ,
142- facultyId : integer ( 'faculty_id' )
143- . references ( ( ) => faculty . id )
141+ id : serial ( 'id' ) . primaryKey ( ) ,
142+ employeeId : varchar ( 'employee_id' , { length : 8 } )
143+ . references ( ( ) => faculty . employeeId )
144144 . notNull ( ) ,
145145 title : text ( 'title' ) . notNull ( ) ,
146146 field : text ( 'field' ) . notNull ( ) ,
147147 date : date ( 'date' ) . notNull ( ) ,
148- place : text ( 'place ' ) . notNull ( ) ,
148+ location : text ( 'location ' ) . notNull ( ) ,
149149} ) ;
150150
151151// Custom Topics Table
152152export const customTopics = pgTable ( 'custom_topics' , {
153153 id : serial ( 'id' ) . primaryKey ( ) ,
154- facultyId : integer ( 'faculty_id' )
155- . references ( ( ) => faculty . id )
154+ employeeId : varchar ( 'employee_id' , { length : 8 } )
155+ . references ( ( ) => faculty . employeeId )
156156 . notNull ( ) ,
157157 name : text ( 'name' ) . notNull ( ) ,
158158} ) ;
@@ -194,6 +194,71 @@ export const facultyRelations = relations(faculty, ({ many, one }) => ({
194194 customTopics : many ( customTopics ) ,
195195} ) ) ;
196196
197- export const customTopicsRelations = relations ( customTopics , ( { many } ) => ( {
198- customInformation : many ( customInformation ) ,
197+ export const qualificationsRelations = relations ( qualifications , ( { one } ) => ( {
198+ faculty : one ( faculty , {
199+ fields : [ qualifications . employeeId ] ,
200+ references : [ faculty . employeeId ] ,
201+ } ) ,
202+ } ) ) ;
203+
204+ export const experienceRelations = relations ( experience , ( { one } ) => ( {
205+ faculty : one ( faculty , {
206+ fields : [ experience . employeeId ] ,
207+ references : [ faculty . employeeId ] ,
208+ } ) ,
209+ } ) ) ;
210+
211+ export const projectsRelations = relations ( projects , ( { one } ) => ( {
212+ faculty : one ( faculty , {
213+ fields : [ projects . employeeId ] ,
214+ references : [ faculty . employeeId ] ,
215+ } ) ,
216+ } ) ) ;
217+
218+ export const continuingEducationRelations = relations (
219+ continuingEducation ,
220+ ( { one } ) => ( {
221+ faculty : one ( faculty , {
222+ fields : [ continuingEducation . employeeId ] ,
223+ references : [ faculty . employeeId ] ,
224+ } ) ,
225+ } )
226+ ) ;
227+
228+ export const publicationsRelations = relations ( publications , ( { one } ) => ( {
229+ faculty : one ( faculty , {
230+ fields : [ publications . employeeId ] ,
231+ references : [ faculty . employeeId ] ,
232+ } ) ,
199233} ) ) ;
234+
235+ export const awardsAndHonorsRelations = relations (
236+ awardsAndHonors ,
237+ ( { one } ) => ( {
238+ faculty : one ( faculty , {
239+ fields : [ awardsAndHonors . employeeId ] ,
240+ references : [ faculty . employeeId ] ,
241+ } ) ,
242+ } )
243+ ) ;
244+
245+ export const customTopicsRelations = relations (
246+ customTopics ,
247+ ( { one, many } ) => ( {
248+ faculty : one ( faculty , {
249+ fields : [ customTopics . employeeId ] ,
250+ references : [ faculty . employeeId ] ,
251+ } ) ,
252+ customInformation : many ( customInformation ) ,
253+ } )
254+ ) ;
255+
256+ export const customInformationRelations = relations (
257+ customInformation ,
258+ ( { one } ) => ( {
259+ customTopic : one ( customTopics , {
260+ fields : [ customInformation . topicId ] ,
261+ references : [ customTopics . id ] ,
262+ } ) ,
263+ } )
264+ ) ;
0 commit comments