/**
 * Port ORM Entity (Infrastructure Layer)
 *
 * TypeORM entity for port persistence
 */

import { Entity, Column, PrimaryColumn, CreateDateColumn, UpdateDateColumn, Index } from 'typeorm';

@Entity('ports')
@Index('idx_ports_code', ['code'])
@Index('idx_ports_country', ['country'])
@Index('idx_ports_active', ['isActive'])
@Index('idx_ports_name_trgm', ['name'])
@Index('idx_ports_city_trgm', ['city'])
@Index('idx_ports_coordinates', ['latitude', 'longitude'])
export class PortOrmEntity {
  @PrimaryColumn('uuid')
  id: string;

  @Column({ type: 'char', length: 5, unique: true })
  code: string;

  @Column({ type: 'varchar', length: 255 })
  name: string;

  @Column({ type: 'varchar', length: 255 })
  city: string;

  @Column({ type: 'char', length: 2 })
  country: string;

  @Column({ name: 'country_name', type: 'varchar', length: 100 })
  countryName: string;

  @Column({ type: 'decimal', precision: 9, scale: 6 })
  latitude: number;

  @Column({ type: 'decimal', precision: 9, scale: 6 })
  longitude: number;

  @Column({ type: 'varchar', length: 50, nullable: true })
  timezone: string | null;

  @Column({ name: 'is_active', type: 'boolean', default: true })
  isActive: boolean;

  @CreateDateColumn({ name: 'created_at' })
  createdAt: Date;

  @UpdateDateColumn({ name: 'updated_at' })
  updatedAt: Date;
}
