import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
import { Season } from './season.entity';

@Entity('episodes')
export class Episode {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column()
  seasonId: string;

  @ManyToOne(() => Season, (season) => season.episodes, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'seasonId' })
  season: Season;

  @Column()
  number: number;

  @Column()
  title: string;

  @Column()
  streamUrl: string;

  @Column({ nullable: true })
  durationMin: number | null;

  @Column({ nullable: true })
  thumbnailUrl: string | null;
}
