"""A seat cap on one organisational unit.""" from __future__ import annotations from sqlalchemy import Column, DateTime, ForeignKey, Integer, func from sqlalchemy.dialects.postgresql import UUID from sqlalchemy.orm import relationship from app.config.database import Base class OrgUnitSeatAllocation(Base): __tablename__ = "org_unit_seat_allocations" id = Column(UUID(as_uuid=True), primary_key=True, server_default=func.gen_random_uuid()) tenant_id = Column(UUID(as_uuid=True), ForeignKey("tenants.id", ondelete="CASCADE"), nullable=False) org_unit_id = Column(UUID(as_uuid=True), ForeignKey("org_units.id", ondelete="CASCADE"), nullable=False) seat_limit = Column(Integer, nullable=False) created_at = Column(DateTime(timezone=True), nullable=False, server_default=func.now()) updated_at = Column(DateTime(timezone=True), nullable=False, server_default=func.now(), onupdate=func.now()) org_unit = relationship("OrgUnit", lazy="raise")