21 lines
914 B
Python
21 lines
914 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 <-> Collection
|
|
product_collections = Table(
|
|
"product_collections",
|
|
Base.metadata,
|
|
Column("product_id", String(26), ForeignKey("products.product_id", ondelete="CASCADE"), primary_key=True),
|
|
Column("collection_id", String(26), ForeignKey("collections.collection_id", ondelete="CASCADE"), primary_key=True)
|
|
)
|
|
|
|
class Collection(Base):
|
|
__tablename__ = "collections"
|
|
|
|
collection_id = Column(String(26), primary_key=True)
|
|
name = Column(String(100), unique=True, nullable=False)
|
|
slug = Column(String(100), unique=True, nullable=False)
|
|
description = Column(String(500), nullable=True)
|
|
is_active = Column(Boolean, default=True)
|
|
created_at = Column(DateTime, server_default=func.now())
|