import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';

export enum Platform {
  ANDROID = 'ANDROID',
  IOS = 'IOS',
}

@Entity('app_versions')
export class AppVersion {
  @PrimaryGeneratedColumn('uuid')
  id!: string;

  @Column({ type: 'enum', enum: Platform })
  platform!: Platform;

  @Column({ type: 'varchar', length: 30 })
  versionName!: string;

  @Column({ type: 'varchar', length: 20 })
  buildNumber!: string;

  @Column({ type: 'text', nullable: true })
  changelog?: string;

  @Column({ type: 'varchar', length: 500, nullable: true })
  downloadUrl?: string;

  @Column({ type: 'bigint', nullable: true })
  fileSize?: number;

  @Column({ type: 'boolean', default: false })
  isForceUpdate!: boolean;

  @Column({ type: 'boolean', default: true })
  isEnabled!: boolean;

  @Column({ type: 'varchar', length: 20, nullable: true })
  minOsVersion?: string;

  @Column({ type: 'timestamptz', nullable: true })
  releaseDate?: Date;

  @CreateDateColumn({ type: 'timestamptz' })
  createdAt!: Date;

  @UpdateDateColumn({ type: 'timestamptz' })
  updatedAt!: Date;
}
