
- Set up FastAPI project structure - Create Task model with SQLAlchemy - Set up Alembic for migrations - Create CRUD operations for tasks - Implement API endpoints for tasks - Add health check endpoint - Update documentation generated with BackendIM... (backend.im)
37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
"""create tasks table
|
|
|
|
Revision ID: 0001
|
|
Revises:
|
|
Create Date: 2025-05-13
|
|
|
|
"""
|
|
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():
|
|
op.create_table(
|
|
'task',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('title', sa.String(255), nullable=False),
|
|
sa.Column('description', sa.Text(), nullable=True),
|
|
sa.Column('is_completed', sa.Boolean(), default=False),
|
|
sa.Column('priority', sa.Integer(), default=1),
|
|
sa.Column('due_date', sa.DateTime(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
|
|
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now(), onupdate=sa.func.now()),
|
|
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') |