diff --git a/models/product.py b/models/product.py new file mode 100644 index 0000000..3b641b2 --- /dev/null +++ b/models/product.py @@ -0,0 +1,16 @@ +from sqlalchemy import Column, String, Integer, Boolean, DateTime, Float +from sqlalchemy.sql import func +from core.database import Base +import uuid + +class Product(Base): + __tablename__ = "products" + id = Column(String, primary_key=True, default=lambda: str(uuid.uuid4())) + name = Column(String, nullable=False, index=True) + description = Column(String, nullable=True) + price = Column(Float, nullable=False) + stock = Column(Integer, nullable=False, default=0) + sku = Column(String, unique=True, nullable=False) + is_active = Column(Boolean, default=True) + created_at = Column(DateTime, default=func.now()) + updated_at = Column(DateTime, default=func.now(), onupdate=func.now()) \ No newline at end of file