import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  Index,
  OneToMany,
} from 'typeorm';
import { Uom } from './uom.entity.js';

@Entity({ schema: 'core', name: 'uom_categories' })
@Index('idx_uom_categories_name', ['name'], { unique: true })
export class UomCategory {
  @PrimaryGeneratedColumn('uuid')
  id: string;

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

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

  // Relations
  @OneToMany(() => Uom, (uom) => uom.category)
  uoms: Uom[];

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