Automated Action 4aac37bc90 Implement inventory management system with FastAPI and SQLite
- Setup project structure with FastAPI application
- Create database models with SQLAlchemy
- Configure Alembic for database migrations
- Implement CRUD operations for products, categories, suppliers
- Add inventory transaction functionality
- Implement user authentication with JWT
- Add health check endpoint
- Create comprehensive documentation
2025-06-05 11:43:07 +00:00

30 lines
1.2 KiB
Python

from sqlalchemy import Column, Integer, String, Float, Text, ForeignKey, Boolean
from sqlalchemy.orm import relationship
from app.db.base_class import Base
class Product(Base):
id = Column(Integer, primary_key=True, index=True)
name = Column(String, index=True, nullable=False)
description = Column(Text, nullable=True)
sku = Column(String, unique=True, index=True, nullable=False)
barcode = Column(String, unique=True, index=True, nullable=True)
quantity = Column(Integer, default=0)
unit_price = Column(Float, nullable=False)
cost_price = Column(Float, nullable=True)
is_active = Column(Boolean, default=True)
min_stock_level = Column(Integer, default=0)
max_stock_level = Column(Integer, default=1000)
# Foreign Keys
category_id = Column(Integer, ForeignKey("category.id"), nullable=True)
supplier_id = Column(Integer, ForeignKey("supplier.id"), nullable=True)
# Relationships
category = relationship("Category", back_populates="products")
supplier = relationship("Supplier", back_populates="products")
inventory_transactions = relationship(
"InventoryTransaction",
back_populates="product",
cascade="all, delete-orphan"
)