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

@Entity('ai_analyses')
export class AIAnalysis {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column()
  campaignId: string;

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

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

  @Column({ type: 'jsonb', nullable: true })
  metrics: any;

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

  @Column({ type: 'date' })
  analysisDate: string; // Stored as YYYY-MM-DD for same-day caching

  @Column({ default: 'standard' })
  tier: string;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;
}
