Files
Messenger/app/media/models.py
2026-03-07 21:31:38 +03:00

17 lines
676 B
Python

from sqlalchemy import ForeignKey, Integer, String
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.database.base import Base
class Attachment(Base):
__tablename__ = "attachments"
id: Mapped[int] = mapped_column(primary_key=True, index=True)
message_id: Mapped[int] = mapped_column(ForeignKey("messages.id", ondelete="CASCADE"), nullable=False, index=True)
file_url: Mapped[str] = mapped_column(String(1024), nullable=False)
file_type: Mapped[str] = mapped_column(String(64), nullable=False)
file_size: Mapped[int] = mapped_column(Integer, nullable=False)
message = relationship("Message", back_populates="attachments")