
Create a full-featured task management API with the following components: - RESTful CRUD operations for tasks - Task status and priority management - SQLite database with SQLAlchemy ORM - Alembic migrations - Health check endpoint - Comprehensive API documentation
40 lines
1.2 KiB
Python
40 lines
1.2 KiB
Python
"""Create tasks table
|
|
|
|
Revision ID: 0001
|
|
Revises:
|
|
Create Date: 2023-09-01 00:00:00.000000
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '0001'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# Create task status enum
|
|
op.create_table(
|
|
'task',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('title', sa.String(255), nullable=False, index=True),
|
|
sa.Column('description', sa.Text(), nullable=True),
|
|
sa.Column('status', sa.Enum('todo', 'in_progress', 'done', name='taskstatus'), nullable=False),
|
|
sa.Column('priority', sa.Enum('low', 'medium', 'high', name='taskpriority'), nullable=False),
|
|
sa.Column('due_date', sa.DateTime(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), nullable=False),
|
|
sa.Column('updated_at', sa.DateTime(), nullable=False),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
op.create_index(op.f('ix_task_id'), 'task', ['id'], unique=False)
|
|
|
|
|
|
def downgrade():
|
|
op.drop_index(op.f('ix_task_id'), table_name='task')
|
|
op.drop_table('task')
|
|
op.execute('DROP TYPE taskstatus')
|
|
op.execute('DROP TYPE taskpriority') |