Enables multi-user project collaboration mirroring the shared calendar pattern. Includes ProjectMember model with permission levels, task assignment with auto-membership, optimistic locking, field allowlist for assignees, disconnect cascade, delta polling for projects and calendars, and full frontend integration with share sheet, assignment picker, permission gating, and notification handling. Migrations: 057 (indexes + version + comment user_id), 058 (project_members), 059 (project_task_assignments) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
24 lines
1005 B
Python
24 lines
1005 B
Python
from sqlalchemy import Text, Integer, ForeignKey
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship as sa_relationship
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
from app.database import Base
|
|
|
|
|
|
class TaskComment(Base):
|
|
__tablename__ = "task_comments"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True, index=True)
|
|
task_id: Mapped[int] = mapped_column(
|
|
Integer, ForeignKey("project_tasks.id", ondelete="CASCADE"), nullable=False, index=True
|
|
)
|
|
user_id: Mapped[Optional[int]] = mapped_column(
|
|
Integer, ForeignKey("users.id", ondelete="SET NULL"), nullable=True
|
|
)
|
|
content: Mapped[str] = mapped_column(Text, nullable=False)
|
|
created_at: Mapped[datetime] = mapped_column(default=datetime.now)
|
|
|
|
# Relationships — lazy="raise" to prevent N+1 (mirrors CalendarMember pattern)
|
|
task: Mapped["ProjectTask"] = sa_relationship(back_populates="comments", lazy="raise")
|
|
user: Mapped[Optional["User"]] = sa_relationship(lazy="raise")
|