
- Add Priority enum (low, medium, high) to Todo model with default medium - Create migration to add priority field to existing todos table - Enhance pagination with proper metadata (page, total, has_next, has_prev) - Add search functionality across title and description fields - Add filtering by completion status and priority level - Update API endpoints with query parameters for filtering and search - Add TodoListResponse schema for structured pagination response - Format code with Ruff
24 lines
697 B
Python
24 lines
697 B
Python
from sqlalchemy import Column, Integer, String, Boolean, DateTime, Enum
|
|
from sqlalchemy.sql import func
|
|
import enum
|
|
|
|
from app.db.base import Base
|
|
|
|
|
|
class Priority(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(200), nullable=False)
|
|
description = Column(String(500), nullable=True)
|
|
completed = Column(Boolean, default=False)
|
|
priority = Column(Enum(Priority), default=Priority.MEDIUM)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|