Add Product model
This commit is contained in:
parent
a1de1d0639
commit
5126073f24
16
models/product.py
Normal file
16
models/product.py
Normal file
@ -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())
|
Loading…
x
Reference in New Issue
Block a user