import { User } from '../../../repositories/users/entity/user.entity';
import {
  Entity,
  Column,
  PrimaryGeneratedColumn,
  JoinColumn,
  ManyToOne,
} from 'typeorm';
import { UserGroup } from './user_group.entity';

@Entity({ name: 'user_group_member' })
export class UserGroupMember {
  @PrimaryGeneratedColumn()
  id: number;

  @Column()
  user_group_id: number;

  @Column()
  user_id: number;

  @Column({ nullable: true })
  deleted_at?: Date;

  @Column()
  created_by: string;

  @Column({ nullable: true })
  created_at?: Date;

  @Column()
  updated_by: string;

  @Column({ nullable: true })
  updated_at?: Date;

  @ManyToOne(() => User, (user) => user.id)
  @JoinColumn({ name: 'user_id' })
  user?: User;

  @ManyToOne(() => UserGroup, (userGroup) => userGroup.id)
  @JoinColumn({ name: 'user_group_id' })
  userGroup?: UserGroup;
}
