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

@Entity({ schema: 'core', name: 'countries' })
@Index('idx_countries_code', ['code'], { unique: true })
export class Country {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ type: 'varchar', length: 2, nullable: false, unique: true })
  code: string;

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

  @Column({ type: 'varchar', length: 10, nullable: true, name: 'phone_code' })
  phoneCode: string | null;

  @Column({
    type: 'varchar',
    length: 3,
    nullable: true,
    name: 'currency_code',
  })
  currencyCode: string | null;

  // Audit fields
  @CreateDateColumn({ name: 'created_at', type: 'timestamp' })
  createdAt: Date;
}
