taskmanagerapi-ao6mr7/migrations/versions/01_initial_migration.py
Automated Action c1765ee96b Implement Task Manager API
- Set up project structure with FastAPI
- Configure SQLite database with SQLAlchemy
- Create Task model with Alembic migrations
- Implement CRUD API endpoints for tasks
- Add health check and CORS configuration
- Update documentation
2025-06-04 08:04:34 +00:00

43 lines
1.3 KiB
Python

"""Initial migration
Revision ID: 01_initial_migration
Revises:
Create Date: 2023-07-09
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '01_initial_migration'
down_revision = None
branch_labels = None
depends_on = None
def upgrade() -> None:
# Create tasks table
op.create_table(
'tasks',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('title', sa.String(length=255), nullable=False),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('is_completed', sa.Boolean(), nullable=False, default=False),
sa.Column('priority', sa.Integer(), nullable=False, default=1),
sa.Column('due_date', sa.DateTime(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=False, server_default=sa.func.now()),
sa.Column('updated_at', sa.DateTime(), nullable=False, server_default=sa.func.now()),
sa.PrimaryKeyConstraint('id')
)
# Create index on title
op.create_index(op.f('ix_tasks_id'), 'tasks', ['id'], unique=False)
op.create_index(op.f('ix_tasks_title'), 'tasks', ['title'], unique=False)
def downgrade() -> None:
# Drop tasks table
op.drop_index(op.f('ix_tasks_title'), table_name='tasks')
op.drop_index(op.f('ix_tasks_id'), table_name='tasks')
op.drop_table('tasks')