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

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

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

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

  @Column({ type: 'simple-json' })
  roles!: string[];

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

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

  @Column({ type: (process.env.NODE_ENV === 'test' && process.env.GRIDPILOT_API_PERSISTENCE !== 'postgres') ? 'datetime' : 'timestamptz', nullable: true })
  lastLoginAt?: Date;

  @CreateDateColumn({ type: (process.env.NODE_ENV === 'test' && process.env.GRIDPILOT_API_PERSISTENCE !== 'postgres') ? 'datetime' : 'timestamptz' })
  createdAt!: Date;

  @UpdateDateColumn({ type: (process.env.NODE_ENV === 'test' && process.env.GRIDPILOT_API_PERSISTENCE !== 'postgres') ? 'datetime' : 'timestamptz' })
  updatedAt!: Date;
}
