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

/**
 * Idempotency tracking table.
 * Kafka consumers record processed event IDs here to prevent duplicate processing.
 * 24-hour idempotency window: entries expire after 24h.
 */
@Entity('processed_events')
export class ProcessedEvent {
  @PrimaryColumn('uuid', { name: 'event_id' })
  eventId: string;

  @Column({ name: 'consumer_group', length: 100 })
  consumerGroup: string;

  @CreateDateColumn({ name: 'processed_at', type: 'timestamptz' })
  processedAt: Date;

  @Column({ name: 'expires_at', type: 'timestamptz' })
  expiresAt: Date;
}
