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

@Entity('uploads')
export class Upload {
    @PrimaryGeneratedColumn('uuid')
    id: string;

    @ManyToOne(() => Users, { onDelete: 'SET NULL', nullable: true })
    @JoinColumn({ name: 'id_utilisateur', referencedColumnName: 'id' })
    user?: Users;

    @Column({ type: 'text', name: 'fichier_url' })
    file_url: string;

    @Column({type: 'varchar', length: 50, nullable: true, name: 'type'})
    type?: string;

    @CreateDateColumn({ name: 'cree_le', type: 'timestamptz' })
    created_at: Date;
}
