546678a30d
docs/planning/social.md US-4, task 6: conversations, conversation_participants, messages (DM + world/room chat), and message_reports, following app/models/social.py's conventions (native enums, explicit index/constraint names, CASCADE FKs where appropriate). Delete behavior, chosen per-relationship: - conversations.user_a_id/user_b_id -> CASCADE: a DM is meaningless with one of its two participants gone, so it cascades away entirely (participants + messages with it). - messages.sender_id -> SET NULL: world/room chat history and reported messages must survive the sender's account being deleted, matching the existing actor-reference convention (WorldChunk.updated_by_id, WorldChunkRevision.actor_id). - messages.world_id/room_id -> CASCADE: chat scoped to a world/room has no meaning once that world/room is gone (mirrors WorldChunk). - message_reports.message_id -> SET NULL (not CASCADE): a moderation report must outlive the message it's about, mirroring WorldChunkRevision's audit-trail-survives-deletion precedent. - message_reports.reporter_id/moderator_id -> SET NULL: audit-actor references, same reasoning. Models + migration only, no endpoints, no text filtering (sibling tasks). Verified: migration upgrade/downgrade/upgrade round-trip against a real Postgres with schema inspected via \d against spec; new model tests cover DM creation, pair uniqueness + ordering check constraint, world/room messages, report defaults, and cascade behavior for both conversation-deletion and sender-deletion; full backend suite (160 tests) passes with no regressions. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y2FESCaMXeJpC9gSctiEeD
18 lines
734 B
Python
18 lines
734 B
Python
from app.models.user import User
|
|
from app.models.session import Session
|
|
from app.models.world import World
|
|
from app.models.asset import Asset
|
|
from app.models.avatar_loadout import AvatarLoadout
|
|
from app.models.world_content import WorldRoom, WorldChunk, WorldChunkRevision
|
|
from app.models.social import Friendship, Follow, Block, FriendshipStatus
|
|
from app.models.chat import (
|
|
Conversation, ConversationParticipant, Message, MessageReport, ReportStatus,
|
|
)
|
|
|
|
__all__ = [
|
|
"User", "Session", "World", "Asset", "AvatarLoadout",
|
|
"WorldRoom", "WorldChunk", "WorldChunkRevision",
|
|
"Friendship", "Follow", "Block", "FriendshipStatus",
|
|
"Conversation", "ConversationParticipant", "Message", "MessageReport", "ReportStatus",
|
|
]
|