restapiservice-0fwiez/alembic/versions/001_initial_migration.py
Automated Action 9d9801c0d0 Create FastAPI REST API service
- Add FastAPI application with CORS support
- Implement SQLite database with SQLAlchemy
- Create Item model with CRUD operations
- Setup Alembic for database migrations
- Add comprehensive API endpoints for Items
- Include health check endpoint
- Update README with documentation
2025-06-19 20:27:19 +00:00

34 lines
1.0 KiB
Python

"""Initial migration
Revision ID: 001
Revises:
Create Date: 2025-06-19 12:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '001'
down_revision = None
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_table('items',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=True),
sa.Column('updated_at', sa.DateTime(timezone=True), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_items_id'), 'items', ['id'], unique=False)
op.create_index(op.f('ix_items_name'), 'items', ['name'], unique=False)
def downgrade() -> None:
op.drop_index(op.f('ix_items_name'), table_name='items')
op.drop_index(op.f('ix_items_id'), table_name='items')
op.drop_table('items')