"""add last_read_at to conversation_participants (DM unread tracking) Revision ID: 0011_add_dm_last_read Revises: 0010_add_profile_tables Create Date: 2026-09-15 00:00:00.000000 app/routers/chat_dm.py (DM send/list/conversations endpoints). Unread-count tracking is implemented as a last-read timestamp per participant: whenever a user fetches a conversation's message history, their ``conversation_participants`` row's ``last_read_at`` is bumped to "now", and the conversation-list endpoint counts messages with ``created_at > last_read_at`` (or all messages if never read) as unread for that participant. Nullable/no default so existing rows (none yet in practice, but consistent with "never read") read as "everything unread". """ from typing import Sequence, Union from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. revision: str = "0011_add_dm_last_read" down_revision: Union[str, None] = "0010_add_profile_tables" branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None def upgrade() -> None: op.add_column( "conversation_participants", sa.Column("last_read_at", sa.DateTime(timezone=True), nullable=True), ) def downgrade() -> None: op.drop_column("conversation_participants", "last_read_at")