
- Implemented project structure with FastAPI framework - Set up SQLite database with SQLAlchemy ORM - Created Alembic for database migrations - Implemented Item model and CRUD operations - Added health check endpoint - Added error handling - Configured API documentation with Swagger UI generated with BackendIM... (backend.im)
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
"""initial
|
|
|
|
Revision ID: 01_initial
|
|
Revises:
|
|
Create Date: 2025-05-13
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '01_initial'
|
|
down_revision = None
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# Create items table
|
|
op.create_table(
|
|
'items',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(100), nullable=False),
|
|
sa.Column('description', sa.Text(), nullable=True),
|
|
sa.Column('price', sa.Integer(), nullable=False),
|
|
sa.Column('is_active', sa.Boolean(), default=True),
|
|
sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.func.now()),
|
|
sa.Column('updated_at', sa.DateTime(timezone=True), onupdate=sa.func.now()),
|
|
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():
|
|
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') |