chore: minor fixes and formatting
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from typing import Optional
|
||||
from sqlalchemy import ForeignKey, Text, Index
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
from sqlalchemy import Boolean, ForeignKey, Index, Text
|
||||
from sqlalchemy.dialects.postgresql import TSVECTOR
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from db.base import Base
|
||||
|
||||
@@ -11,7 +10,7 @@ class Category(Base):
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
name: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
parent_id: Mapped[Optional[int]] = mapped_column(ForeignKey("categories.id"))
|
||||
parent_id: Mapped[int | None] = mapped_column(ForeignKey("categories.id"))
|
||||
|
||||
parent: Mapped["Category"] = relationship("Category", remote_side=[id])
|
||||
|
||||
@@ -20,15 +19,14 @@ class Product(Base):
|
||||
__tablename__ = "products"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
category_id: Mapped[Optional[int]] = mapped_column(ForeignKey("categories.id"))
|
||||
category_id: Mapped[int | None] = mapped_column(ForeignKey("categories.id"))
|
||||
name: Mapped[str] = mapped_column(Text, nullable=False)
|
||||
description: Mapped[Optional[str]] = mapped_column(Text)
|
||||
description: Mapped[str | None] = mapped_column(Text)
|
||||
price: Mapped[int] = mapped_column()
|
||||
img_path: Mapped[str] = mapped_column(Text, nullable=True)
|
||||
file_id: Mapped[str] = mapped_column(Text, nullable=True, unique=True)
|
||||
is_hidden: Mapped[bool] = mapped_column(Boolean, default=False, nullable=False)
|
||||
|
||||
search_vector: Mapped[str] = mapped_column(TSVECTOR)
|
||||
|
||||
__table_args__ = (
|
||||
Index("idx_products_search", "search_vector", postgresql_using="gin"),
|
||||
)
|
||||
__table_args__ = (Index("idx_products_search", "search_vector", postgresql_using="gin"),)
|
||||
|
||||
Reference in New Issue
Block a user