inventorymanagementapp-8wys9g/migrations/versions/001_create_inventory_items_table.py
Automated Action 667ac548e1 Build complete FastAPI inventory management application
- Created FastAPI application structure with SQLAlchemy and Alembic
- Implemented full CRUD operations for inventory items
- Added search, filtering, and pagination capabilities
- Configured CORS, API documentation, and health endpoints
- Set up SQLite database with proper migrations
- Added comprehensive API documentation and README
2025-07-21 19:29:24 +00:00

44 lines
1.9 KiB
Python

"""Create inventory items table
Revision ID: 001
Revises:
Create Date: 2024-01-01 00:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
revision = '001'
down_revision = None
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_table(
'inventory_items',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=255), nullable=False),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('sku', sa.String(length=100), nullable=False),
sa.Column('quantity', sa.Integer(), nullable=False),
sa.Column('price', sa.Float(), nullable=False),
sa.Column('category', sa.String(length=100), nullable=True),
sa.Column('supplier', sa.String(length=255), nullable=True),
sa.Column('location', sa.String(length=255), 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), server_default=sa.text('CURRENT_TIMESTAMP'), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_inventory_items_id'), 'inventory_items', ['id'], unique=False)
op.create_index(op.f('ix_inventory_items_name'), 'inventory_items', ['name'], unique=False)
op.create_index(op.f('ix_inventory_items_sku'), 'inventory_items', ['sku'], unique=True)
op.create_index(op.f('ix_inventory_items_category'), 'inventory_items', ['category'], unique=False)
def downgrade() -> None:
op.drop_index(op.f('ix_inventory_items_category'), table_name='inventory_items')
op.drop_index(op.f('ix_inventory_items_sku'), table_name='inventory_items')
op.drop_index(op.f('ix_inventory_items_name'), table_name='inventory_items')
op.drop_index(op.f('ix_inventory_items_id'), table_name='inventory_items')
op.drop_table('inventory_items')