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

/**
 * Tracks which users have read which notifications.
 * userId is from the JWT (public.users.id).
 */
@Entity({ name: 'notification_reads', schema: 'public' })
@Unique(['notificationId', 'userId'])
export class NotificationRead {
  @PrimaryGeneratedColumn('uuid')
  id!: string;

  @Column({ name: 'notification_id', type: 'uuid' })
  @Index()
  notificationId!: string;

  @Column({ name: 'user_id', type: 'varchar', length: 100 })
  @Index()
  userId!: string;

  @Column({ name: 'tenant_id', type: 'varchar', length: 100 })
  tenantId!: string;

  @CreateDateColumn({ name: 'read_at', type: 'timestamptz' })
  readAt!: Date;
}
