todoapp-vgv7cg/alembic/versions/007_add_due_date.py
Automated Action aa7cc98275 Implement comprehensive due date API endpoints with filtering and sorting
Added comprehensive due date functionality to the FastAPI todo application:

API Enhancements:
- Updated main /todos endpoint with due date query parameters (overdue, due_soon, due_date_from, due_date_to)
- Added sort_by parameter supporting "due_date" and "created_at" options
- Enhanced existing endpoints to handle due_date in responses

New Specialized Endpoints:
- GET /api/v1/todos/overdue - Get all overdue todos with pagination
- GET /api/v1/todos/due-soon - Get todos due within next N days (default 7)
- GET /api/v1/todos/due-today - Get todos due today with date range filtering

Technical Improvements:
- Added comprehensive OpenAPI documentation with parameter descriptions and examples
- Implemented proper date validation and timezone handling
- Added date utility functions for consistent date operations
- Enhanced error handling for invalid date parameters
- Added proper FastAPI Query parameter validation with regex patterns

Migration & Schema Updates:
- Created migration 007 to add due_date column with timezone support
- Added database index on due_date for optimal query performance
- Updated Todo model with computed properties (is_overdue, days_until_due, is_due_soon)
- Enhanced schemas with due_date field validation and Field descriptions

All endpoints follow existing API patterns with pagination, filtering, and comprehensive documentation.
2025-06-19 13:22:25 +00:00

33 lines
739 B
Python

"""Add due_date field to todos table
Revision ID: 007
Revises: 006
Create Date: 2025-06-19 12:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = "007"
down_revision = "006"
branch_labels = None
depends_on = None
def upgrade() -> None:
# Add due_date column to todos table
op.add_column(
"todos",
sa.Column("due_date", sa.DateTime(timezone=True), nullable=True),
)
# Add index for better performance on due date queries
op.create_index(op.f("ix_todos_due_date"), "todos", ["due_date"], unique=False)
def downgrade() -> None:
op.drop_index(op.f("ix_todos_due_date"), table_name="todos")
op.drop_column("todos", "due_date")