import {
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  DeleteDateColumn,
  Index,
} from 'typeorm';

/**
 * Base entity para todas las entidades multi-tenant.
 * Todas las entidades de negocio DEBEN extender esta clase.
 *
 * @example
 * @Entity('clients', { schema: 'crm' })
 * export class Client extends TenantAwareEntity {
 *   @PrimaryGeneratedColumn('uuid')
 *   id: string;
 *
 *   @Column({ length: 255 })
 *   name: string;
 * }
 */
export abstract class TenantAwareEntity {
  @Column('uuid')
  @Index()
  tenant_id: string;

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

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

  @DeleteDateColumn({ type: 'timestamptz' })
  deleted_at: Date | null;
}
