import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, Index, ManyToOne, JoinColumn, } from 'typeorm'; import { SubscriptionPlan } from './subscription-plan.entity.js'; /** * PlanFeature Entity * Maps to billing.plan_features DDL table * Features disponibles por plan de suscripcion * Propagated from template-saas HU-REFACT-005 */ @Entity({ schema: 'billing', name: 'plan_features' }) @Index('idx_plan_features_plan', ['planId']) @Index('idx_plan_features_key', ['featureKey']) export class PlanFeature { @PrimaryGeneratedColumn('uuid') id: string; @Column({ type: 'uuid', nullable: false, name: 'plan_id' }) planId: string; @Column({ type: 'varchar', length: 100, nullable: false, name: 'feature_key' }) featureKey: string; @Column({ type: 'varchar', length: 255, nullable: false, name: 'feature_name' }) featureName: string; @Column({ type: 'varchar', length: 100, nullable: true }) category: string | null; @Column({ type: 'boolean', default: true }) enabled: boolean; @Column({ type: 'jsonb', default: {} }) configuration: Record; @Column({ type: 'text', nullable: true }) description: string | null; @Column({ type: 'jsonb', default: {} }) metadata: Record; // Relaciones @ManyToOne(() => SubscriptionPlan, { onDelete: 'CASCADE' }) @JoinColumn({ name: 'plan_id' }) plan: SubscriptionPlan; // Timestamps @CreateDateColumn({ name: 'created_at', type: 'timestamptz' }) createdAt: Date; @UpdateDateColumn({ name: 'updated_at', type: 'timestamptz' }) updatedAt: Date; }