Files
main_backend/cpv3/modules/files/models.py
T
2026-02-03 02:15:07 +03:00

39 lines
1.3 KiB
Python

from __future__ import annotations
import uuid
from sqlalchemy import BigInteger, Boolean, ForeignKey, String
from sqlalchemy.dialects.postgresql import UUID
from sqlalchemy.orm import Mapped, mapped_column
from cpv3.db.base import Base, BaseModelMixin
class File(Base, BaseModelMixin):
__tablename__ = "files"
project_id: Mapped[uuid.UUID | None] = mapped_column(
UUID(as_uuid=True),
ForeignKey("projects.id", ondelete="RESTRICT"),
nullable=True,
index=True,
)
owner_id: Mapped[uuid.UUID | None] = mapped_column(
UUID(as_uuid=True),
ForeignKey("users.id", ondelete="RESTRICT"),
nullable=True,
index=True,
)
original_filename: Mapped[str] = mapped_column(String(255), default="")
path: Mapped[str] = mapped_column(String(1024))
storage_backend: Mapped[str] = mapped_column(String(16), default="S3")
mime_type: Mapped[str] = mapped_column(String(128))
size_bytes: Mapped[int] = mapped_column(BigInteger)
checksum: Mapped[str | None] = mapped_column(String(64), nullable=True)
file_format: Mapped[str | None] = mapped_column(String(32), nullable=True)
is_uploaded: Mapped[bool] = mapped_column(Boolean, default=False)
is_deleted: Mapped[bool] = mapped_column(Boolean, default=False)