import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, Index } from 'typeorm';
import { ClientPricing } from './client-pricing.entity';

@Entity('client_pricing_tiers')
export class ClientPricingTier {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ type: 'varchar', length: 100 })
  @Index() // To allow fast querying by name
  name: string;

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

  @Column({ type: 'simple-array', nullable: true, name: 'main_features' })
  features: string[];

  @Column({ type: 'decimal', precision: 10, scale: 2 })
  price: number;

  @ManyToOne(() => ClientPricing, pricing => pricing.tiers, {
    onDelete: 'CASCADE',
    nullable: false,
  })
  pricing: ClientPricing;
}
