20 lines
734 B
Python
20 lines
734 B
Python
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime
|
|
from sqlalchemy.orm import relationship
|
|
from sqlalchemy.sql import func
|
|
|
|
from app.db.base_class import Base
|
|
|
|
|
|
class InventoryItem(Base):
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
quantity = Column(Integer, default=0, nullable=False)
|
|
location = Column(String, nullable=True)
|
|
last_updated = Column(DateTime, default=func.now(), onupdate=func.now())
|
|
min_stock_level = Column(Integer, default=0)
|
|
max_stock_level = Column(Integer, default=0)
|
|
|
|
# Foreign keys
|
|
product_id = Column(Integer, ForeignKey("product.id"), nullable=False)
|
|
|
|
# Relationships
|
|
product = relationship("Product", back_populates="inventory_items") |