import {
  Column,
  Entity,
  PrimaryGeneratedColumn,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
import { Role } from './role.entity';
import { PolymorphicAuthor } from './core/polymorphic-author';

@Entity('role_authors')
export class RoleAuthor extends PolymorphicAuthor {
  @Column()
  role_id: number;

  @ManyToOne(() => Role, (role) => role.role_authors, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'role_id' })
  role: Role;
}
