import { DB_SCHEMA } from 'src/utils';
import {
  Column,
  Entity,
  JoinColumn,
  ManyToOne,
  OneToMany,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { UserEntity } from './User.entity';
import { CenterLocationEntity } from './CenterLocation.entity';

@Entity('user_branch', { schema: DB_SCHEMA })
export class UserBranchEntity {
  @PrimaryGeneratedColumn({ type: 'smallint', name: 'user_branch_id' })
  user_branch_id: number;

  @Column('smallint', { name: 'user_id' })
  user_id: number;

  @Column('tinyint', { name: 'center_id' })
  center_id: number;

  @Column('smallint', { name: 'by_user', nullable: true })
  by_user: number | null;

  @ManyToOne(() => CenterLocationEntity)
  @JoinColumn({ name: 'center_id', referencedColumnName: 'center_id' })
  center: CenterLocationEntity;
}
