第一次提交
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"""上传图片元数据(文件本体存 S3)。"""
|
||||
|
||||
from sqlalchemy import BigInteger, ForeignKey, String, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.models.base import new_uuid
|
||||
from app.db import Base, TimestampMixin
|
||||
|
||||
|
||||
class Image(Base, TimestampMixin):
|
||||
__tablename__ = "images"
|
||||
|
||||
id: Mapped[str] = mapped_column(String(36), primary_key=True, default=new_uuid)
|
||||
user_id: Mapped[str] = mapped_column(
|
||||
ForeignKey("users.id", ondelete="CASCADE"), index=True
|
||||
)
|
||||
object_key: Mapped[str] = mapped_column(String(512)) # S3 中的 key
|
||||
mime: Mapped[str] = mapped_column(String(64))
|
||||
size_bytes: Mapped[int] = mapped_column(BigInteger)
|
||||
sha256: Mapped[str] = mapped_column(String(64), index=True) # 去重
|
||||
# 缓存原始 OCR 文本:一张图可能拆成多条笔记,留着便于追溯与重新拆分
|
||||
ocr_markdown: Mapped[str | None] = mapped_column(Text, nullable=True)
|
||||
Reference in New Issue
Block a user