import { EntitySchema } from 'typeorm'

export type StudentProfileEntity = {
  id: string
  classId: string
  className: string
  name: string
  englishName: string
  gender: string
  birthday: string
  zodiac: string
  friends: string
  hobbies: string
  favoriteGames: string
  favoriteFoods: string
  traits: string
  comment: string
  commentGeneratedAt: string
  importedAt: string
}

export const StudentProfileEntitySchema = new EntitySchema<StudentProfileEntity>({
  name: 'StudentProfileEntity',
  tableName: 'student_profiles',
  columns: {
    id: {
      type: String,
      primary: true
    },
    classId: {
      name: 'class_id',
      type: String
    },
    className: {
      name: 'class_name',
      type: String
    },
    name: {
      type: String,
      default: ''
    },
    englishName: {
      name: 'english_name',
      type: String,
      default: ''
    },
    gender: {
      type: String,
      default: ''
    },
    birthday: {
      type: String,
      default: ''
    },
    zodiac: {
      type: String,
      default: ''
    },
    friends: {
      type: String,
      default: '[]'
    },
    hobbies: {
      type: String,
      default: '[]'
    },
    favoriteGames: {
      name: 'favorite_games',
      type: String,
      default: '[]'
    },
    favoriteFoods: {
      name: 'favorite_foods',
      type: String,
      default: '[]'
    },
    traits: {
      type: String,
      default: ''
    },
    comment: {
      type: String,
      default: ''
    },
    commentGeneratedAt: {
      name: 'comment_generated_at',
      type: String,
      default: ''
    },
    importedAt: {
      name: 'imported_at',
      type: String,
      default: ''
    }
  },
  indices: [
    {
      name: 'idx_student_profiles_class_id',
      columns: ['classId']
    }
  ],
  relations: {}
})
