Files
Edu/services/core-edu/src/leave-requests/leave-requests.schema.ts

44 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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;