auto id length in bi ref: interaction
This commit is contained in:
@@ -1,13 +1,27 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import Column, DateTime, String, ForeignKey, UniqueConstraint
|
||||
from sqlalchemy.sql import func
|
||||
from .base import AutoID, Base
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .user import User
|
||||
from .project import ProjectNode
|
||||
from .workspace import Workspace
|
||||
|
||||
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)
|
||||
user_id = Column(
|
||||
String(User.id_length()),
|
||||
ForeignKey("users.id", ondelete="CASCADE"),
|
||||
index=True
|
||||
)
|
||||
project_node_id = Column(
|
||||
String(ProjectNode.id_length()),
|
||||
ForeignKey("project_nodes.id", ondelete="CASCADE"),
|
||||
index=True
|
||||
)
|
||||
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
@@ -19,8 +33,16 @@ 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)
|
||||
user_id = Column(
|
||||
String(User.id_length()),
|
||||
ForeignKey("users.id", ondelete="CASCADE"),
|
||||
index=True
|
||||
)
|
||||
project_node_id = Column(
|
||||
String(ProjectNode.id_length()),
|
||||
ForeignKey("project_nodes.id", ondelete="CASCADE"),
|
||||
index=True
|
||||
)
|
||||
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
@@ -32,13 +54,25 @@ 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)
|
||||
user_id = Column(
|
||||
String(User.id_length()),
|
||||
ForeignKey("users.id", ondelete="CASCADE"),
|
||||
index=True
|
||||
)
|
||||
project_node_id = Column(
|
||||
String(ProjectNode.id_length()),
|
||||
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)
|
||||
target_workspace_id = Column(
|
||||
String(Workspace.id_length()),
|
||||
ForeignKey("workspaces.id", ondelete="SET NULL"),
|
||||
nullable=True
|
||||
)
|
||||
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
Reference in New Issue
Block a user