auto id length in bi ref: project
This commit is contained in:
+15
-2
@@ -1,14 +1,27 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from sqlalchemy import Column, DateTime, String, ForeignKey, Integer
|
||||
from sqlalchemy.sql import func
|
||||
from .base import AutoID, Base
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .workspace import Workspace
|
||||
|
||||
class ProjectItem(Base, AutoID):
|
||||
"""项目与文件夹的树状虚拟文件系统"""
|
||||
__tablename__ = "project_items"
|
||||
|
||||
workspace_id = Column(String(32), ForeignKey("workspaces.id", ondelete="CASCADE"), index=True)
|
||||
workspace_id = Column(
|
||||
String(Workspace.id_length()),
|
||||
ForeignKey("workspaces.id", ondelete="CASCADE"),
|
||||
index=True,
|
||||
)
|
||||
# 自引用外键:如果是根目录下的顶级节点,则 parent_id 为 Null
|
||||
parent_id = Column(String(32), ForeignKey("project_items.id", ondelete="CASCADE"), nullable=True, index=True)
|
||||
parent_id = Column(
|
||||
String(AutoID.id_length()), # 其实调用的就是自身的 id_length 方法
|
||||
ForeignKey("project_items.id", ondelete="CASCADE"),
|
||||
nullable=True,
|
||||
index=True,
|
||||
)
|
||||
|
||||
name = Column(String, nullable=False)
|
||||
# 节点类型:'folder' (文件夹) 或 'project' (代表具体文件的项目实体)
|
||||
|
||||
Reference in New Issue
Block a user