
- Added priority field (low, medium, high) to Todo model - Created migration for priority field addition - Updated API schemas to include priority - Added filtering by priority in GET todos endpoint - Updated README to reflect new features
38 lines
798 B
Python
38 lines
798 B
Python
"""add priority field to todos
|
|
|
|
Revision ID: 002
|
|
Revises: 001
|
|
Create Date: 2023-08-21
|
|
|
|
"""
|
|
|
|
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():
|
|
# Create priority_level enum type
|
|
priority_type = sa.Enum("low", "medium", "high", name="prioritylevel")
|
|
priority_type.create(op.get_bind())
|
|
|
|
# Add priority column to todos table with default value of 'medium'
|
|
op.add_column(
|
|
"todos",
|
|
sa.Column("priority", priority_type, nullable=False, server_default="medium"),
|
|
)
|
|
|
|
|
|
def downgrade():
|
|
# Drop priority column
|
|
op.drop_column("todos", "priority")
|
|
|
|
# Drop the enum type
|
|
sa.Enum(name="prioritylevel").drop(op.get_bind())
|