Files
resolutionflow/backend/app/models/attachment.py
Michael Chihlas 52e8190211 Initial commit: Backend API Phase 1a complete
- FastAPI backend with JWT auth
- PostgreSQL database schema
- Trees and Sessions CRUD APIs
- Export functionality (Markdown, Text, HTML)
- Docker setup for local development
- Alembic migrations
2026-01-22 14:38:53 -05:00

35 lines
1.2 KiB
Python

import uuid
from datetime import datetime
from typing import Optional
from sqlalchemy import String, Integer, DateTime, ForeignKey
from sqlalchemy.orm import Mapped, mapped_column, relationship
from sqlalchemy.dialects.postgresql import UUID
from app.core.database import Base
class Attachment(Base):
__tablename__ = "attachments"
id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True),
primary_key=True,
default=uuid.uuid4
)
session_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True),
ForeignKey("sessions.id"),
nullable=False
)
node_id: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
file_name: Mapped[str] = mapped_column(String(255), nullable=False)
file_type: Mapped[Optional[str]] = mapped_column(String(50), nullable=True)
file_size: Mapped[Optional[int]] = mapped_column(Integer, nullable=True)
storage_path: Mapped[Optional[str]] = mapped_column(String(500), nullable=True)
uploaded_at: Mapped[datetime] = mapped_column(
DateTime,
default=datetime.utcnow
)
# Relationships
session: Mapped["Session"] = relationship("Session", back_populates="attachments")