Automated Action 4dc182713c Implement Small Business Inventory Management System
- Created project structure with FastAPI framework
- Set up SQLite database with SQLAlchemy ORM
- Implemented models: User, Item, Supplier, Transaction
- Created CRUD operations for all models
- Added API endpoints for all resources
- Implemented JWT authentication and authorization
- Added Alembic migration scripts
- Created health endpoint
- Updated documentation

generated with BackendIM... (backend.im)
2025-05-13 09:48:37 +00:00

27 lines
997 B
Python

from sqlalchemy import Column, Integer, String, Float, ForeignKey, DateTime
from sqlalchemy.orm import relationship
from sqlalchemy.sql import func
from app.db.base_class import Base
class Item(Base):
id = Column(Integer, primary_key=True, index=True)
name = Column(String, index=True)
description = Column(String, nullable=True)
sku = Column(String, index=True, unique=True)
quantity = Column(Integer, default=0)
unit_price = Column(Float, nullable=False)
category = Column(String, index=True)
location = Column(String, nullable=True)
# Timestamps
created_at = Column(DateTime(timezone=True), server_default=func.now())
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
# Foreign Keys
supplier_id = Column(Integer, ForeignKey("supplier.id"), nullable=True)
# Relationships
supplier = relationship("Supplier", back_populates="items")
transactions = relationship("Transaction", back_populates="item")