Automated Action 5f63459832 Add priority feature for todos
- Add priority field to Todo model
- Update Pydantic schemas with priority field
- Create Alembic migration for priority column
- Add filter by priority to GET /todos endpoint
- Update README with new feature details

generated with BackendIM... (backend.im)
2025-05-13 06:28:44 +00:00

29 lines
707 B
Python

"""add_priority_field
Revision ID: 002
Revises: 001
Create Date: 2025-05-13
"""
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:
op.add_column('todos', sa.Column('priority', sa.Integer(), nullable=True, server_default='1'))
op.create_index(op.f('ix_todos_priority'), 'todos', ['priority'], unique=False)
# Set default value for existing rows
op.execute("UPDATE todos SET priority = 1 WHERE priority IS NULL")
def downgrade() -> None:
op.drop_index(op.f('ix_todos_priority'), table_name='todos')
op.drop_column('todos', 'priority')