
- 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
30 lines
1.2 KiB
Python
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"
|
|
) |