// src/modules/customers/entities/customer-phone.entity.ts
import {
  Column,
  Entity,
  PrimaryGeneratedColumn,
  ManyToOne,
  JoinColumn,
  CreateDateColumn,
  UpdateDateColumn,
  DeleteDateColumn,
} from "typeorm"
import { Customer } from "./customer.entity"

@Entity("customer_phone_numbers")
export class CustomerPhoneNumbers {
  @PrimaryGeneratedColumn()
  id: number

  @Column({ type: "int" })
  customer_id: number

  @Column({ type: "varchar" })
  country_code: string

  @Column({ type: "varchar" })
  phone_number: string

  @Column({ type: "varchar", nullable: true })
  type: string

  @Column({ type: "boolean", default: false })
  is_primary: boolean

  @ManyToOne(() => Customer, (customer) => customer.phone_numbers, {
    onDelete: "CASCADE",
  })
  @JoinColumn({ name: "customer_id" })
  customer: Customer

  @CreateDateColumn({ type: "timestamp", default: () => "NOW()" })
  created_at: Date

  @UpdateDateColumn({ type: "timestamp", default: () => "NOW()" })
  updated_at: Date

  @DeleteDateColumn({ type: "timestamp", nullable: true })
  deleted_at: Date
}
