Automated Action 20e3b39596 Fix database migration error by re-exporting Base
- Add Base import to models/base.py to re-export it properly
- Fix issue where models/__init__.py was trying to import Base from models/base.py
- Add noqa comment to suppress unused import warning
- Maintain the same model architecture but with correct imports
2025-05-27 19:04:39 +00:00

25 lines
700 B
Python

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()