import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm';

@Entity('associates')
export class Associates {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ type: 'int' })
  user_id: number;

  // Location fields (matching companies pattern)
  @Column({ type: 'int', nullable: true })
  country_id: number;

  @Column({ type: 'int', nullable: true })
  state_id: number;

  @Column({ type: 'int', nullable: true })
  city_id: number;

  @Column({ type: 'int', nullable: true })
  area_id: number;

  @Column({ type: 'text', nullable: true })
  address: string;

  @Column({ type: 'varchar', length: 10, nullable: true })
  pincode: string;

  @Column({ type: 'decimal', precision: 10, scale: 8, nullable: true })
  latitude: number;

  @Column({ type: 'decimal', precision: 11, scale: 8, nullable: true })
  longitude: number;

  // Metadata
  @Column({ type: 'int', nullable: true })
  created_by: number;

  @Column({ type: 'tinyint', default: 1 })
  status: number;

  @Column({
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
  })
  created_at: Date;

  @Column({
    type: 'timestamp',
    default: () => 'CURRENT_TIMESTAMP',
    onUpdate: 'CURRENT_TIMESTAMP',
  })
  updated_at: Date;
}
