import uuid
from datetime import datetime, timezone
from typing import Optional
from sqlalchemy import String, Text, DateTime, ForeignKey, func
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy.dialects.postgresql import UUID
from app.core.database import Base


class BetaFeedback(Base):
    __tablename__ = "beta_feedback"

    id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
    user_id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
    reaction: Mapped[str] = mapped_column(String(10), nullable=False)  # 'positive', 'neutral', 'negative'
    category: Mapped[Optional[str]] = mapped_column(String(30), nullable=True)  # 'bug', 'feature', 'confusing', 'praise'
    text: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
    page_url: Mapped[Optional[str]] = mapped_column(String(500), nullable=True)
    session_id: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)  # FlowPilot session ID if applicable
    created_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), server_default=func.now())
