import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  ManyToOne,
  JoinColumn,
  CreateDateColumn,
  UpdateDateColumn,
} from 'typeorm';
import { Users } from './users.entity';

@Entity('configuration')
export class Configuration {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ type: 'varchar', length: 100, unique: true, nullable: false })
  cle: string;

  @Column({ type: 'text', nullable: true })
  valeur: string | null;

  @Column({ type: 'varchar', length: 50, nullable: false })
  type: 'string' | 'number' | 'boolean' | 'json' | 'encrypted';

  @Column({ type: 'varchar', length: 50, nullable: true })
  categorie: 'email' | 'app' | 'security' | null;

  @Column({ type: 'text', nullable: true })
  description: string | null;

  @UpdateDateColumn({ name: 'modifie_le' })
  modifieLe: Date;

  @ManyToOne(() => Users, { nullable: true })
  @JoinColumn({ name: 'modifie_par' })
  modifiePar: Users | null;
}

