21 lines
1,023 B
Python
21 lines
1,023 B
Python
from sqlalchemy import Column, String, Boolean, DateTime, ForeignKey
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
from app.core.database.db_session import Base
|
|
|
|
class Category(Base):
|
|
__tablename__ = "categories"
|
|
|
|
category_id = Column(String(26), primary_key=True)
|
|
parent_category_id = Column(String(26), ForeignKey("categories.category_id", ondelete="SET NULL"), nullable=True)
|
|
name = Column(String(100), nullable=False)
|
|
slug = Column(String(100), unique=True, nullable=False)
|
|
description = Column(String(500), nullable=True)
|
|
image_url = Column(String(500), nullable=True)
|
|
sort_order = Column(String(10), default="0")
|
|
is_parent_feature = Column(Boolean, default=False, nullable=False)
|
|
is_active = Column(Boolean, default=True)
|
|
created_at = Column(DateTime, server_default=func.now())
|
|
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now())
|
|
|
|
parent = relationship("Category", remote_side=[category_id], backref="children")
|