diff --git a/backend/app/models/base.py b/backend/app/models/base.py new file mode 100644 index 0000000..b5f3d84 --- /dev/null +++ b/backend/app/models/base.py @@ -0,0 +1,19 @@ +"""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)