"""YakPanel - Site redirect model"""
from sqlalchemy import String, Integer, ForeignKey
from sqlalchemy.orm import Mapped, mapped_column
from app.core.database import Base


class SiteRedirect(Base):
    __tablename__ = "site_redirects"

    id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
    site_id: Mapped[int] = mapped_column(Integer, ForeignKey("sites.id"), nullable=False)
    source: Mapped[str] = mapped_column(String(512), nullable=False)  # e.g. /old-path or domain.com/old
    target: Mapped[str] = mapped_column(String(512), nullable=False)  # e.g. /new-path or https://...
    code: Mapped[int] = mapped_column(Integer, default=301)  # 301 or 302
