Automated Action fe3924497e Add todo due date and priority features
- Added priority (low, medium, high) to todo items
- Added due date to todo items
- Enhanced API to support filtering by priority and due date
- Added overdue and due_soon filters for better task management
- Automatic sorting by priority and due date
- Created alembic migration for the new fields
- Updated documentation

generated with BackendIM... (backend.im)
2025-05-14 01:27:39 +00:00

31 lines
994 B
Python

from sqlalchemy import Boolean, Column, Integer, String, DateTime, CheckConstraint
from sqlalchemy.sql import func
from app.db.base import Base
import enum
class PriorityEnum(str, enum.Enum):
LOW = "low"
MEDIUM = "medium"
HIGH = "high"
class Todo(Base):
__tablename__ = "todos"
id = Column(Integer, primary_key=True, index=True)
title = Column(String, index=True)
description = Column(String, nullable=True)
completed = Column(Boolean, default=False)
priority = Column(String(10), default=PriorityEnum.MEDIUM.value)
due_date = Column(DateTime(timezone=True), nullable=True)
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
# Add a check constraint to ensure priority is one of the allowed values
__table_args__ = (
CheckConstraint(
"priority IN ('low', 'medium', 'high')",
name="priority_check"
),
)