Add app/models/product.py
This commit is contained in:
20
app/models/product.py
Normal file
20
app/models/product.py
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import uuid
|
||||||
|
from datetime import datetime
|
||||||
|
from sqlalchemy import Column, String, DateTime, Integer, Numeric, ForeignKey
|
||||||
|
from sqlalchemy.orm import relationship
|
||||||
|
from app.database import Base
|
||||||
|
|
||||||
|
|
||||||
|
class Product(Base):
|
||||||
|
__tablename__ = "products"
|
||||||
|
|
||||||
|
id = Column(String(36), primary_key=True, default=lambda: str(uuid.uuid4()))
|
||||||
|
sku = Column(String(50), unique=True, nullable=False)
|
||||||
|
name = Column(String(200), nullable=False)
|
||||||
|
description = Column(String(1000), nullable=True)
|
||||||
|
category_id = Column(String(36), ForeignKey("categories.id"), nullable=True)
|
||||||
|
price = Column(Numeric(10, 2), nullable=False)
|
||||||
|
min_stock = Column(Integer, default=0)
|
||||||
|
current_stock = Column(Integer, default=0)
|
||||||
|
created_at = Column(DateTime, default=datetime.utcnow)
|
||||||
|
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||||
Reference in New Issue
Block a user