project & library table

This commit is contained in:
2026-05-17 22:39:20 +08:00
parent 0dd31f5a4f
commit 7813731ea9
2 changed files with 43 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
from sqlalchemy import Column, DateTime, String, ForeignKey, BigInteger
from sqlalchemy.sql import func
from .base import AutoID, Base
class LibraryItem(Base, AutoID):
"""工作区共享媒体/文件资源库"""
__tablename__ = "library_items"
workspace_id = Column(String(32), ForeignKey("workspaces.id", ondelete="CASCADE"), index=True)
# 自引用外键,支持无限级文件夹嵌套
parent_id = Column(String(32), ForeignKey("library_items.id", ondelete="CASCADE"), nullable=True, index=True)
name = Column(String, nullable=False)
# 节点类型:'folder' (文件夹) 或 'file' (真实文件)
item_type = Column(String, default="file", nullable=False)
# --- 以下为真实文件(item_type='file')的核心字段 ---
s3_key = Column(String, nullable=True) # S3 中的 Object Key
file_size = Column(BigInteger, nullable=True) # 文件大小(字节数 Bytes),用于统计容量占用
mime_type = Column(String, nullable=True) # 媒体类型,例如 'image/jpeg', 'video/mp4', 'application/pdf'
uploaded_by = Column(String(32), ForeignKey("users.id", ondelete="SET NULL"), nullable=True)
created_at = Column(DateTime(timezone=True), server_default=func.now())