
- 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)
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""Add due_date and priority fields to todo
|
|
|
|
Revision ID: add_due_date_and_priority
|
|
Revises: initial_migration
|
|
Create Date: 2025-05-14 00:00:00.000000
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = 'add_due_date_and_priority'
|
|
down_revision = 'initial_migration'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# SQLite doesn't support ENUM types natively, so we'll use a string with a CHECK constraint
|
|
with op.batch_alter_table('todos') as batch_op:
|
|
batch_op.add_column(sa.Column('priority', sa.String(10), nullable=False, server_default='medium'))
|
|
batch_op.add_column(sa.Column('due_date', sa.DateTime(timezone=True), nullable=True))
|
|
# Add a check constraint to ensure priority is one of the allowed values
|
|
batch_op.create_check_constraint(
|
|
'priority_check',
|
|
"priority IN ('low', 'medium', 'high')"
|
|
)
|
|
|
|
|
|
def downgrade():
|
|
with op.batch_alter_table('todos') as batch_op:
|
|
batch_op.drop_constraint('priority_check')
|
|
batch_op.drop_column('due_date')
|
|
batch_op.drop_column('priority') |