add social interactions, rich media metadata, and workspace description

This commit is contained in:
2026-05-17 22:49:26 +08:00
parent 3f79d1d85a
commit 333dd9dd35
3 changed files with 58 additions and 3 deletions
+44
View File
@@ -0,0 +1,44 @@
from sqlalchemy import Column, DateTime, String, ForeignKey, UniqueConstraint
from sqlalchemy.sql import func
from .base import AutoID, Base
class ProjectLike(Base, AutoID):
"""项目点赞表"""
__tablename__ = "project_likes"
user_id = Column(String(32), ForeignKey("users.id", ondelete="CASCADE"), index=True)
project_node_id = Column(String(32), ForeignKey("project_nodes.id", ondelete="CASCADE"), index=True)
created_at = Column(DateTime(timezone=True), server_default=func.now())
# 联合唯一约束,防止同一用户重复点赞
__table_args__ = (UniqueConstraint("user_id", "project_node_id", name="uq_user_project_like"),)
class ProjectFavorite(Base, AutoID):
"""项目收藏表"""
__tablename__ = "project_favorites"
user_id = Column(String(32), ForeignKey("users.id", ondelete="CASCADE"), index=True)
project_node_id = Column(String(32), ForeignKey("project_nodes.id", ondelete="CASCADE"), index=True)
created_at = Column(DateTime(timezone=True), server_default=func.now())
# 联合唯一约束,防止重复收藏
__table_args__ = (UniqueConstraint("user_id", "project_node_id", name="uq_user_project_favorite"),)
class ProjectShare(Base, AutoID):
"""项目转发/分享记录表"""
__tablename__ = "project_shares"
user_id = Column(String(32), ForeignKey("users.id", ondelete="CASCADE"), index=True)
project_node_id = Column(String(32), ForeignKey("project_nodes.id", ondelete="CASCADE"), index=True)
# 转发去向或渠道,例如 'internal' (转发到其他工作区), 'twitter', 'link' (复制链接)
share_target = Column(String, default="internal", nullable=False)
# 如果是转发到特定工作区,可以记录目标工作区 ID
target_workspace_id = Column(String(32), ForeignKey("workspaces.id", ondelete="SET NULL"), nullable=True)
created_at = Column(DateTime(timezone=True), server_default=func.now())