import { EntitySchema } from 'typeorm'

export type ReportEntity = {
  id: string
  title: string
  classId: string
  className: string
  studentId: string
  studentName: string
  format: string
  originalFileName: string
  filePath: string
  fileExtension: string
  templateId: string
  createdAt: string
  updatedAt: string
}

export const ReportEntitySchema = new EntitySchema<ReportEntity>({
  name: 'ReportEntity',
  tableName: 'reports',
  columns: {
    id: {
      type: String,
      primary: true
    },
    title: {
      type: String
    },
    classId: {
      name: 'class_id',
      type: String
    },
    className: {
      name: 'class_name',
      type: String
    },
    studentId: {
      name: 'student_id',
      type: String
    },
    studentName: {
      name: 'student_name',
      type: String
    },
    format: {
      type: String
    },
    originalFileName: {
      name: 'original_file_name',
      type: String
    },
    filePath: {
      name: 'file_path',
      type: String
    },
    fileExtension: {
      name: 'file_extension',
      type: String
    },
    templateId: {
      name: 'template_id',
      type: String
    },
    createdAt: {
      name: 'created_at',
      type: String
    },
    updatedAt: {
      name: 'updated_at',
      type: String
    }
  },
  indices: [
    {
      name: 'idx_reports_class_id',
      columns: ['classId']
    },
    {
      name: 'idx_reports_student_name',
      columns: ['studentName']
    }
  ],
  relations: {}
})
