import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  DeleteDateColumn,
  Index,
} from "typeorm"
import { CONTENT_FORMAT } from "src/constants/app-content.constant"

@Entity("app_content")
export class AppContent {
  @PrimaryGeneratedColumn()
  id: number

  /** Zero padded to at least 3 digits, e.g. "001", "099", "100". */
  @Index("IDX_app_content_field_ref_no", { unique: true })
  @Column({ type: "varchar", length: 10, nullable: false })
  field_ref_no: string

  @Column({ type: "text", nullable: true })
  title?: string

  @Column({
    type: "varchar",
    length: 10,
    nullable: false,
    default: CONTENT_FORMAT.TEXT,
  })
  title_format: string

  @Column({ type: "text", nullable: true })
  description?: string

  @Column({
    type: "varchar",
    length: 10,
    nullable: false,
    default: CONTENT_FORMAT.TEXT,
  })
  description_format: string

  @CreateDateColumn({ type: "timestamp", nullable: true })
  created_at?: Date

  @UpdateDateColumn({ type: "timestamp", nullable: true })
  updated_at?: Date

  @DeleteDateColumn({ type: "timestamp", nullable: true })
  deleted_at?: Date
}
