from sqlalchemy import BigInteger, String, UniqueConstraint
from sqlalchemy.orm import Mapped, mapped_column

from app.core.models.base import Base, TenantMixin, TimestampMixin


class NewsletterSubscription(Base, TenantMixin, TimestampMixin):
    __tablename__ = "newsletter_subscriptions"
    __table_args__ = (
        UniqueConstraint("tenant_id", "email", name="uk_newsletter_tenant_email"),
        {"mysql_engine": "InnoDB", "mysql_charset": "utf8mb4", "mysql_collate": "utf8mb4_unicode_ci"},
    )

    id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
    email: Mapped[str] = mapped_column(String(255), nullable=False)
