22 lines
888 B
Python
22 lines
888 B
Python
from sqlalchemy import Boolean, Column, Float, Integer, String, Text
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.session import Base
|
|
|
|
|
|
class Product(Base):
|
|
__tablename__ = "products"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
name = Column(String, index=True, nullable=False)
|
|
sku = Column(String, unique=True, index=True, nullable=False)
|
|
description = Column(Text)
|
|
weight = Column(Float, nullable=False, default=0.0) # in kg
|
|
dimensions = Column(String) # format: "length x width x height" in cm
|
|
price = Column(Float, nullable=False, default=0.0)
|
|
is_active = Column(Boolean, default=True)
|
|
|
|
# Relationships
|
|
inventory_items = relationship("Inventory", back_populates="product")
|
|
order_items = relationship("OrderItem", back_populates="product")
|
|
shipment_items = relationship("ShipmentItem", back_populates="product") |