/**
 * Plan Setting Entity
 * Default configuration per subscription plan
 * Hierarchy: system_settings < plan_settings < tenant_settings
 * Compatible with erp-core plan-setting.entity
 *
 * @module Settings
 */

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

@Entity({ name: 'plan_settings', schema: 'core_settings' })
@Unique(['planId', 'key'])
export class PlanSetting {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Index()
  @Column({ name: 'plan_id', type: 'uuid' })
  planId: string;

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

  @Column({ name: 'value', type: 'jsonb' })
  value: any;

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

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