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

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

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

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

  @Column({ name: 'is_enabled', default: true })
  isEnabled: boolean;

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