38 lines
1.5 KiB
Python
38 lines
1.5 KiB
Python
from datetime import datetime
|
|
from decimal import Decimal
|
|
|
|
from sqlalchemy import Boolean, DateTime, Numeric, String, Text, func
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from app.database import Base
|
|
|
|
|
|
class Category(Base):
|
|
__tablename__ = "categories"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
slug: Mapped[str] = mapped_column(String(64), unique=True, index=True)
|
|
name: Mapped[str] = mapped_column(String(120))
|
|
description: Mapped[str] = mapped_column(Text, default="")
|
|
sort_order: Mapped[int] = mapped_column(default=0)
|
|
|
|
|
|
class Product(Base):
|
|
__tablename__ = "products"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
slug: Mapped[str] = mapped_column(String(120), unique=True, index=True)
|
|
title: Mapped[str] = mapped_column(String(200))
|
|
short_description: Mapped[str] = mapped_column(String(300))
|
|
description: Mapped[str] = mapped_column(Text, default="")
|
|
price: Mapped[Decimal] = mapped_column(Numeric(10, 2))
|
|
currency: Mapped[str] = mapped_column(String(3), default="RUB")
|
|
category_slug: Mapped[str] = mapped_column(String(64), index=True)
|
|
image_gradient: Mapped[str] = mapped_column(String(120), default="mint")
|
|
is_featured: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
is_active: Mapped[bool] = mapped_column(Boolean, default=True)
|
|
delivery_note: Mapped[str] = mapped_column(String(200), default="Мгновенная выдача")
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), server_default=func.now()
|
|
)
|