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

/**
 * ORM Entity: ExternalGameRatingProfile
 * 
 * Stores external game rating profiles per user and game.
 * Uses JSONB for ratings map and provenance data.
 */
@Entity({ name: 'external_game_rating_profiles' })
@Index(['userId', 'gameKey'], { unique: true })
@Index(['userId'])
@Index(['gameKey'])
export class ExternalGameRatingProfileOrmEntity {
  @PrimaryColumn({ type: 'text' })
  userId!: string;

  @PrimaryColumn({ type: 'text' })
  gameKey!: string;

  @Column({ type: 'jsonb' })
  ratings!: Array<{
    type: string;
    gameKey: string;
    value: number;
  }>;

  @Column({ type: 'jsonb' })
  provenance!: {
    source: string;
    lastSyncedAt: Date;
    verified: boolean;
  };

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

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