import { Column, Entity, PrimaryColumn } from 'typeorm';

import type {
    SerializedSeasonDropPolicy,
    SerializedSeasonSchedule,
    SerializedSeasonScoringConfig,
    SerializedSeasonStewardingConfig,
} from '../serialized/RacingTypeOrmSerialized';

@Entity({ name: 'racing_seasons' })
export class SeasonOrmEntity {
  @PrimaryColumn({ type: 'uuid' })
  id!: string;

  @Column({ type: 'uuid' })
  leagueId!: string;

  @Column({ type: 'text' })
  gameId!: string;

  @Column({ type: 'text' })
  name!: string;

  @Column({ type: 'int', nullable: true })
  year!: number | null;

  @Column({ type: 'int', nullable: true })
  order!: number | null;

  @Column({ type: 'text' })
  status!: string;

  @Column({ type: 'timestamptz', nullable: true })
  startDate!: Date | null;

  @Column({ type: 'timestamptz', nullable: true })
  endDate!: Date | null;

  @Column({ type: 'jsonb', nullable: true })
  schedule!: SerializedSeasonSchedule | null;

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

  @Column({ type: 'jsonb', nullable: true })
  scoringConfig!: SerializedSeasonScoringConfig | null;

  @Column({ type: 'jsonb', nullable: true })
  dropPolicy!: SerializedSeasonDropPolicy | null;

  @Column({ type: 'jsonb', nullable: true })
  stewardingConfig!: SerializedSeasonStewardingConfig | null;

  @Column({ type: 'int', nullable: true })
  maxDrivers!: number | null;

  @Column({ type: 'int', default: 0 })
  participantCount!: number;
}