Files
ai-worker-platform/backend/app/models/base.py
T

20 lines
673 B
Python

"""Base model and common mixins."""
from datetime import datetime
from sqlalchemy import Column, Integer, DateTime, String
from app.database import Base
class TimestampMixin:
"""Adds created_at and updated_at columns."""
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False)
class TenantMixin:
"""Adds tenant_id column for multi-tenant isolation.
Every domain model inherits this to guarantee row-level tenant isolation.
Queries must always filter by tenant_id.
"""
tenant_id = Column(Integer, nullable=False, index=True)