44 lines
1.1 KiB
TypeScript
44 lines
1.1 KiB
TypeScript
/**
|
|
* Tenant Entity - Multi-tenancy organization
|
|
*
|
|
* @module @erp-suite/core/entities
|
|
*/
|
|
|
|
import { Entity, Column } from 'typeorm';
|
|
import { BaseEntity } from './base.entity';
|
|
|
|
/**
|
|
* Tenant entity for multi-tenancy support
|
|
*
|
|
* Each tenant represents an independent organization with isolated data.
|
|
* All other entities reference tenant_id for Row-Level Security (RLS).
|
|
*
|
|
* @example
|
|
* ```typescript
|
|
* const tenant = new Tenant();
|
|
* tenant.name = 'Acme Corp';
|
|
* tenant.slug = 'acme-corp';
|
|
* tenant.status = 'active';
|
|
* ```
|
|
*/
|
|
@Entity('tenants', { schema: 'auth' })
|
|
export class Tenant extends BaseEntity {
|
|
@Column({ type: 'varchar', length: 255 })
|
|
name: string;
|
|
|
|
@Column({ type: 'varchar', length: 100, unique: true })
|
|
slug: string;
|
|
|
|
@Column({ type: 'varchar', length: 50, default: 'active' })
|
|
status: 'active' | 'inactive' | 'suspended';
|
|
|
|
@Column({ type: 'jsonb', nullable: true })
|
|
settings?: Record<string, unknown>;
|
|
|
|
@Column({ type: 'varchar', length: 255, nullable: true })
|
|
domain?: string;
|
|
|
|
@Column({ type: 'text', nullable: true })
|
|
logo_url?: string;
|
|
}
|