"""add beta_feedback table

Revision ID: 065
Revises: 064
Create Date: 2026-03-23 00:00:00.000000

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects.postgresql import UUID


# revision identifiers, used by Alembic.
revision: str = "065"
down_revision: Union[str, None] = "064"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    op.create_table(
        "beta_feedback",
        sa.Column("id", UUID(as_uuid=True), primary_key=True),
        sa.Column("user_id", UUID(as_uuid=True), sa.ForeignKey("users.id", ondelete="CASCADE"), nullable=False),
        sa.Column("reaction", sa.String(10), nullable=False),
        sa.Column("category", sa.String(30), nullable=True),
        sa.Column("text", sa.Text, nullable=True),
        sa.Column("page_url", sa.String(500), nullable=True),
        sa.Column("session_id", sa.String(100), nullable=True),
        sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now()),
    )
    op.create_index("ix_beta_feedback_user_id", "beta_feedback", ["user_id"])
    op.create_index("ix_beta_feedback_reaction", "beta_feedback", ["reaction"])
    op.create_index("ix_beta_feedback_created_at", "beta_feedback", ["created_at"])


def downgrade() -> None:
    op.drop_index("ix_beta_feedback_created_at", table_name="beta_feedback")
    op.drop_index("ix_beta_feedback_reaction", table_name="beta_feedback")
    op.drop_index("ix_beta_feedback_user_id", table_name="beta_feedback")
    op.drop_table("beta_feedback")
