"""comment_reactions: an emoji on a comment, Slack's way

Revision ID: a2c4e6f8b0d2
Revises: f8b0c2d4e6a8
Create Date: 2026-09-17

A quick "agreed" or "seen it" that needs no reply. One row per person per
emoji on a comment; pressing the same emoji again removes the row.
"""
from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

revision: str = 'a2c4e6f8b0d2'
down_revision: Union[str, Sequence[str], None] = 'f8b0c2d4e6a8'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.create_table(
        'comment_reactions',
        sa.Column('id', sa.Integer(), nullable=False),
        sa.Column('comment_id', sa.Integer(), nullable=False),
        sa.Column('username', sa.String(length=64), nullable=False),
        sa.Column('emoji', sa.String(length=16), nullable=False),
        sa.Column('created_at', sa.DateTime(timezone=True), nullable=False),
        sa.ForeignKeyConstraint(['comment_id'], ['comment.id'], ondelete='CASCADE'),
        sa.PrimaryKeyConstraint('id'),
        sa.UniqueConstraint('comment_id', 'username', 'emoji'),
    )
    op.create_index(op.f('ix_comment_reactions_comment_id'), 'comment_reactions',
                    ['comment_id'], unique=False)


def downgrade() -> None:
    op.drop_index(op.f('ix_comment_reactions_comment_id'), table_name='comment_reactions')
    op.drop_table('comment_reactions')
