
- Add due_date field as nullable DateTime with timezone support - Add is_overdue property to check if task is overdue - Add days_until_due property for time calculations - Create migration 007 to add due_date column with index - Maintain backward compatibility with nullable due_date
32 lines
738 B
Python
32 lines
738 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") |