44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import {
|
||
mysqlTable,
|
||
varchar,
|
||
text,
|
||
timestamp,
|
||
char,
|
||
date,
|
||
index,
|
||
} from "drizzle-orm/mysql-core";
|
||
|
||
// 请假申请表(P3.13 新增)
|
||
export const leaveRequests = mysqlTable(
|
||
"core_edu_leave_requests",
|
||
{
|
||
id: char("id", { length: 36 }).notNull().primaryKey(),
|
||
studentId: char("student_id", { length: 36 }).notNull(),
|
||
classId: char("class_id", { length: 36 }).notNull(),
|
||
leaveType: varchar("leave_type", { length: 20 }).notNull(),
|
||
startDate: date("start_date").notNull(),
|
||
endDate: date("end_date").notNull(),
|
||
reason: text("reason").notNull(),
|
||
status: varchar("status", { length: 20 }).notNull().default("pending"),
|
||
submittedBy: char("submitted_by", { length: 36 }).notNull(),
|
||
reviewedBy: char("reviewed_by", { length: 36 }),
|
||
reviewComment: text("review_comment"),
|
||
schoolId: char("school_id", { length: 36 }).notNull(),
|
||
createdAt: timestamp("created_at").notNull().defaultNow(),
|
||
updatedAt: timestamp("updated_at").notNull().defaultNow().onUpdateNow(),
|
||
},
|
||
(table) => ({
|
||
idxLeaveRequestsStudent: index("idx_leave_requests_student").on(
|
||
table.studentId,
|
||
),
|
||
idxLeaveRequestsClass: index("idx_leave_requests_class").on(table.classId),
|
||
idxLeaveRequestsStatus: index("idx_leave_requests_status").on(table.status),
|
||
idxLeaveRequestsSchool: index("idx_leave_requests_school").on(
|
||
table.schoolId,
|
||
),
|
||
}),
|
||
);
|
||
|
||
export type LeaveRequest = typeof leaveRequests.$inferSelect;
|
||
export type NewLeaveRequest = typeof leaveRequests.$inferInsert;
|