"""Flags on comments (rian's card design of 14 Sep): a personal marker, one row per person and
comment, so the panel can show "what I flagged".

Schema only. Revises `f0a1b2c3d4e5`, the single head at the time of writing.

Revision ID: f1a2b3c4d5e6
Revises: f0a1b2c3d4e5
Create Date: 2026-09-14
"""

import sqlalchemy as sa

from alembic import op

revision = "f1a2b3c4d5e6"
down_revision = "f0a1b2c3d4e5"
branch_labels = None
depends_on = None


def upgrade() -> None:
    op.create_table(
        "comment_flags",
        sa.Column("id", sa.Integer(), primary_key=True),
        sa.Column("comment_id", sa.Integer(), sa.ForeignKey("discussion_comments.id"), nullable=False),
        sa.Column("account_id", sa.Integer(), sa.ForeignKey("accounts.id"), nullable=False),
        sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now(), nullable=False),
        sa.UniqueConstraint("comment_id", "account_id", name="uq_comment_flag"),
    )
    op.create_index("ix_comment_flags_account_id", "comment_flags", ["account_id"])


def downgrade() -> None:
    op.drop_index("ix_comment_flags_account_id", table_name="comment_flags")
    op.drop_table("comment_flags")
