Skip to content

Commit e1aef29

Browse files
committed
fix: integrating deans' office in staff schema
1 parent e8d02df commit e1aef29

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

server/db/schema/deans.schema.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { relations, sql } from 'drizzle-orm';
22
import { pgTable } from 'drizzle-orm/pg-core';
33

4-
import { faculty } from '.';
4+
import { faculty, staff } from '.';
55

66
export const deans = pgTable('deans', (t) => ({
77
id: t.smallserial().primaryKey(),
@@ -24,19 +24,14 @@ export const deans = pgTable('deans', (t) => ({
2424
.references(() => faculty.id)
2525
.notNull(),
2626
associateFacultyId: t.integer().references(() => faculty.id),
27-
staffIds: t
28-
.integer()
29-
.array()
30-
.default(sql`'{}'`)
31-
.notNull(),
3227
activityLogs: t
3328
.text()
3429
.array()
3530
.default(sql`'{}'`)
3631
.notNull(),
3732
}));
3833

39-
export const deansRelations = relations(deans, ({ one }) => ({
34+
export const deansRelations = relations(deans, ({ one, many }) => ({
4035
faculty: one(faculty, {
4136
fields: [deans.facultyId],
4237
references: [faculty.id],
@@ -45,4 +40,5 @@ export const deansRelations = relations(deans, ({ one }) => ({
4540
fields: [deans.associateFacultyId],
4641
references: [faculty.id],
4742
}),
43+
staff: many(staff),
4844
}));

server/db/schema/staff.schema.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { relations } from 'drizzle-orm';
22
import { pgTable, uniqueIndex } from 'drizzle-orm/pg-core';
33

4-
import { departments, persons, sections } from '.';
4+
import { deans, departments, persons, sections } from '.';
55

66
export 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

Comments
 (0)