Files
character-roleplay-backend/app/models/project.py
T
2026-05-17 22:39:20 +08:00

20 lines
985 B
Python

from sqlalchemy import Column, DateTime, String, ForeignKey
from sqlalchemy.sql import func
from .base import AutoID, Base
class ProjectNode(Base, AutoID):
"""项目与文件夹的树状虚拟文件系统"""
__tablename__ = "project_nodes"
workspace_id = Column(String(32), ForeignKey("workspaces.id", ondelete="CASCADE"), index=True)
# 自引用外键:如果是根目录下的顶级节点,则 parent_id 为 Null
parent_id = Column(String(32), ForeignKey("project_nodes.id", ondelete="CASCADE"), nullable=True, index=True)
name = Column(String, nullable=False)
# 节点类型:'folder' (文件夹) 或 'project' (代表具体文件的项目实体)
node_type = Column(String, default="project", nullable=False)
# 如果是 project 节点,可以用这一列来存储其内容或配置快照(如 JSON 文本)
content = Column(String, nullable=True)
created_at = Column(DateTime(timezone=True), server_default=func.now())