import { Entity, Column, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { ProfileAbility } from "./ProfileAbility";

@Entity("profileAbilityHistory")
export class ProfileAbilityHistory extends EntityBase {
  @Column({
    nullable: true,
    comment: "หมายเหตุ",
    type: "text",
    default: null,
  })
  remark: string;

  @Column({
    nullable: true,
    comment: "รายละเอียด",
    type: "text",
    default: null,
  })
  detail: string;

  @Column({
    nullable: true,
    comment: "เอกสารอ้างอิง",
    type: "text",
    default: null,
  })
  reference: string;

  @Column({
    nullable: true,
    type: "datetime",
    comment: "วันที่เริ่มต้น",
    default: null,
  })
  dateStart: Date;

  @Column({
    nullable: true,
    type: "datetime",
    comment: "วันที่สิ้นสุด",
    default: null,
  })
  dateEnd: Date;

  @Column({
    nullable: true,
    comment: "ด้าน",
    type: "text",
    default: null,
  })
  field: string;

  @Column({
    comment: "แนบไฟล์เอกสาร",
    default: false,
  })
  isUpload: boolean;

  @Column({
    nullable: true,
    length: 40,
    comment: "คีย์นอก(FK)ของตาราง ProfileAbility",
    default: null,
  })
  profileAbilityId: string;

  @Column({
    nullable: false,
    comment: "สถานะลบข้อมูล",
    default: false,
  })
  isDeleted: boolean;

  @ManyToOne(() => ProfileAbility, (profileAbility) => profileAbility.profileAbilityHistorys)
  @JoinColumn({ name: "profileAbilityId" })
  histories: ProfileAbility;
}
