import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  ManyToOne,
  JoinColumn,
} from "typeorm"
import { BaseEntity } from "../../common/entities/base.entity"
import { Project } from "./project.entity"
import { PartyTypeCategory } from "../../party-types/entities/party-type.entity"

@Entity("project_party_assignments")
export class ProjectPartyAssignment extends BaseEntity {
  @PrimaryGeneratedColumn()
  id: number

  @Column({ type: "int", nullable: false })
  project_id: number

  @Column({ type: "int", nullable: false })
  party_id: number

  @Column({
    type: "enum",
    enum: PartyTypeCategory,
    nullable: false,
  })
  party_type: PartyTypeCategory

  @ManyToOne(() => Project)
  @JoinColumn({ name: "project_id" })
  project: Project
}
