20 lines
798 B
Python
20 lines
798 B
Python
from sqlalchemy import Column, String, Boolean, DateTime, ForeignKey, Table
|
|
from sqlalchemy.sql import func
|
|
from app.core.database.db_session import Base
|
|
|
|
# Many-to-many helper table for Product <-> Tag
|
|
product_tags = Table(
|
|
"product_tags",
|
|
Base.metadata,
|
|
Column("product_id", String(26), ForeignKey("products.product_id", ondelete="CASCADE"), primary_key=True),
|
|
Column("tag_id", String(26), ForeignKey("tags.tag_id", ondelete="CASCADE"), primary_key=True)
|
|
)
|
|
|
|
class Tag(Base):
|
|
__tablename__ = "tags"
|
|
|
|
tag_id = Column(String(26), primary_key=True)
|
|
name = Column(String(100), unique=True, nullable=False)
|
|
slug = Column(String(100), unique=True, nullable=False)
|
|
is_active = Column(Boolean, default=True)
|
|
created_at = Column(DateTime, server_default=func.now())
|