19 lines
701 B
Python
19 lines
701 B
Python
from sqlalchemy import Boolean, Column, DateTime, Float, Integer, String, Text
|
|
from sqlalchemy.sql import func
|
|
|
|
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)
|
|
description = Column(Text, nullable=True)
|
|
price = Column(Float, nullable=False, index=True)
|
|
stock = Column(Integer, nullable=False, default=0)
|
|
image_url = Column(String, nullable=True)
|
|
is_active = Column(Boolean, default=True)
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), onupdate=func.now())
|