18 lines
757 B
Python
18 lines
757 B
Python
from sqlalchemy import ForeignKey, Integer, String, Text
|
|
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)
|
|
waveform_data: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
|
|
message = relationship("Message", back_populates="attachments")
|