import {
  Column,
  Entity,
  JoinColumn,
  ManyToOne,
  PrimaryGeneratedColumn,
  Unique,
} from 'typeorm';
import { Timestamp } from './timestamp';
import { Bid } from './bid.entity';

@Entity('send_message_histories')
@Unique(['max_price', 'type', 'reserve_price', 'bid'])
export class SendMessageHistory extends Timestamp {
  @PrimaryGeneratedColumn('increment')
  id: number;

  @Column({ default: null, nullable: true, type: 'text' })
  message: string;

  @Column({ default: 'biding' })
  type: string;

  @ManyToOne(() => Bid, (bid) => bid.sendMessageHistories, {
    onDelete: 'CASCADE',
  })
  bid: Bid;

  @Column({ default: 0, nullable: true })
  max_price: number;

  @Column({ default: 0, nullable: true })
  reserve_price: number;
}
