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

import type { SerializedLeagueSettings } from '../serialized/RacingTypeOrmSerialized';

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

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

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

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

  @Column({ type: 'jsonb' })
  settings!: SerializedLeagueSettings;

  @Column({ type: 'text', nullable: true })
  category!: string | null;

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

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

  @Column({ type: 'text', nullable: true })
  discordUrl!: string | null;

  @Column({ type: 'text', nullable: true })
  youtubeUrl!: string | null;

  @Column({ type: 'text', nullable: true })
  websiteUrl!: string | null;

  @Column({ type: 'jsonb', nullable: true })
  logoRef!: Record<string, unknown> | null;
}