from sqlalchemy import Column, DateTime from sqlalchemy.ext.declarative import declared_attr from datetime import datetime from app.db.session import Base # Re-export Base # noqa: F401 class TimestampMixin: """Mixin that adds created_at and updated_at columns to models.""" created_at = Column(DateTime, default=datetime.utcnow, nullable=False) updated_at = Column( DateTime, default=datetime.utcnow, onupdate=datetime.utcnow, nullable=False ) class TableNameMixin: """Mixin that automatically sets the table name based on the class name.""" @declared_attr def __tablename__(cls) -> str: return cls.__name__.lower()