"""
题图设置模型 — SQLModel

只存当前展示的一张题图，不动 episodes 表。
"""

from datetime import datetime

from sqlalchemy import Column
from sqlalchemy import DateTime as SADateTime
from sqlalchemy import Integer as SAInteger
from sqlalchemy import Text
from sqlalchemy.sql import func as sa_func
from sqlmodel import Field, SQLModel


class CoverSettings(SQLModel, table=True):
    __tablename__ = "cover_settings"

    id: int | None = Field(default=None, primary_key=True)
    key: str = Field(default="dashboard_cover", max_length=50)
    cover_path: str | None = Field(default=None)        # 当前题图文件路径
    episode_number: int | None = Field(default=None)   # 关联期次号
    episode_title: str | None = Field(default=None)    # 关联期次节目名
    updated_at: datetime | None = Field(
        default=None,
        sa_column=Column(SADateTime(timezone=True), nullable=False, server_default=sa_func.now()),
    )