Files
bianchengshequ/backend/models/attachment.py

19 lines
885 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""附件模型"""
from sqlalchemy import Column, Integer, String, BigInteger, DateTime, ForeignKey
from sqlalchemy.sql import func
from database import Base
class Attachment(Base):
__tablename__ = "attachments"
id = Column(Integer, primary_key=True, index=True)
post_id = Column(Integer, nullable=True, default=None, index=True) # 新建文章时为null发布后回填
user_id = Column(Integer, ForeignKey("users.id"), nullable=False)
filename = Column(String(255), nullable=False) # 原始文件名
storage_key = Column(String(500), nullable=False) # COS对象键
url = Column(String(500), nullable=False) # 完整访问URL
file_size = Column(BigInteger, nullable=False) # 文件大小(字节)
file_type = Column(String(100), nullable=False) # MIME类型
created_at = Column(DateTime(timezone=True), server_default=func.now())