
- Set up project structure for FastAPI application - Create database models for items, categories, suppliers, and transactions - Set up Alembic for database migrations - Implement API endpoints for all entities - Add authentication with JWT tokens - Add health check endpoint - Create comprehensive README with documentation
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
from sqlalchemy import Column, String, Text, Integer, Float, ForeignKey
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.base import Base
|
|
from app.db.base_class import BaseModel
|
|
|
|
|
|
class Item(Base, BaseModel):
|
|
"""Inventory item model."""
|
|
__tablename__ = "items"
|
|
|
|
name = Column(String, index=True, nullable=False)
|
|
description = Column(Text, nullable=True)
|
|
sku = Column(String, index=True, unique=True, nullable=True)
|
|
barcode = Column(String, index=True, unique=True, nullable=True)
|
|
quantity = Column(Integer, default=0, nullable=False)
|
|
unit_price = Column(Float, nullable=True)
|
|
reorder_level = Column(Integer, default=0, nullable=True)
|
|
location = Column(String, nullable=True)
|
|
|
|
# Foreign keys
|
|
category_id = Column(Integer, ForeignKey("categories.id"), nullable=True)
|
|
supplier_id = Column(Integer, ForeignKey("suppliers.id"), nullable=True)
|
|
owner_id = Column(Integer, ForeignKey("users.id"), nullable=False)
|
|
|
|
# Relationships
|
|
category = relationship("Category", back_populates="items")
|
|
supplier = relationship("Supplier", back_populates="items")
|
|
owner = relationship("User", back_populates="items")
|
|
transactions = relationship("Transaction", back_populates="item") |