
- 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
38 lines
878 B
Python
38 lines
878 B
Python
"""Add priority field to todos
|
|
|
|
Revision ID: 002
|
|
Revises: 001
|
|
Create Date: 2024-01-01 00:00:00.000000
|
|
|
|
"""
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = "002"
|
|
down_revision = "001"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.add_column(
|
|
"todos",
|
|
sa.Column(
|
|
"priority",
|
|
sa.Enum("LOW", "MEDIUM", "HIGH", name="priority"),
|
|
nullable=True,
|
|
),
|
|
)
|
|
# Set default value for existing records
|
|
op.execute("UPDATE todos SET priority = 'MEDIUM' WHERE priority IS NULL")
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade() -> None:
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.drop_column("todos", "priority")
|
|
# ### end Alembic commands ###
|