import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
import { UserProfile } from './user-profile.entity';

@Entity({ schema: 'auth', name: 'profile_tools' })
export class ProfileTool {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ type: 'uuid', nullable: false, name: 'profile_id' })
  profileId: string;

  @Column({ type: 'varchar', length: 50, nullable: false, name: 'tool_code' })
  toolCode: string;

  @Column({ name: 'can_view', default: false })
  canView: boolean;

  @Column({ name: 'can_create', default: false })
  canCreate: boolean;

  @Column({ name: 'can_edit', default: false })
  canEdit: boolean;

  @Column({ name: 'can_delete', default: false })
  canDelete: boolean;

  @ManyToOne(() => UserProfile, (p) => p.tools, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'profile_id' })
  profile: UserProfile;
}
