import {
  mysqlTable,
  varchar,
  text,
  timestamp,
  char,
  datetime,
} from 'drizzle-orm/mysql-core';

export const exams = mysqlTable('core_edu_exams', {
  id: char('id', { length: 36 }).notNull().primaryKey(),
  classId: char('class_id', { length: 36 }).notNull(),
  title: varchar('title', { length: 200 }).notNull(),
  description: text('description'),
  examDate: datetime('exam_date').notNull(),
  duration: varchar('duration', { length: 50 }).notNull(),
  totalScore: varchar('total_score', { length: 10 }).notNull(),
  status: varchar('status', { length: 20 }).notNull().default('draft'),
  createdBy: char('created_by', { length: 36 }).notNull(),
  createdAt: timestamp('created_at').notNull().defaultNow(),
  updatedAt: timestamp('updated_at').notNull().defaultNow().onUpdateNow(),
});

export type Exam = typeof exams.$inferSelect;
export type NewExam = typeof exams.$inferInsert;
