import datetime
from typing import Optional

from sqlmodel import BigInteger, Column, DateTime, Field, ForeignKey, SQLModel


class HelpSessionBase(SQLModel):
    """A base model for storing information about users."""

    claimant_id: int
    channel_id: int
    opened_at: datetime.datetime
    closed_at: Optional[datetime.datetime]


class HelpSessionTable(HelpSessionBase, table=True):
    """A model for storing information about individual help sessions."""

    __tablename__ = "help_sessions"

    session_id: int = Field(primary_key=True)
    claimant_id: int = Field(
        sa_column=Column(
            "claimant_id",
            BigInteger,
            ForeignKey("users.user_id"),
            nullable=False
        )
    )
    channel_id: int = Field(
        sa_column=Column(
            "channel_id",
            BigInteger,
            index=True,
            nullable=False
        )
    )
    opened_at: datetime.datetime = Field(
        sa_column=Column(
            DateTime(timezone=True),
            nullable=False
        )
    )
    closed_at: Optional[datetime.datetime] = Field(
        sa_column=Column(
            DateTime(timezone=True),
            nullable=True
        )
    )

sqlmodel.Field sqlmodel.DateTime sqlmodel.Column sqlmodel.ForeignKey
[((526, 549), 'sqlmodel.Field', 'Field', ([], {'primary_key': '(True)'}), '(primary_key=True)\n', (531, 549), False, 'from sqlmodel import BigInteger, Column, DateTime, Field, ForeignKey, SQLModel\n'), ((788, 848), 'sqlmodel.Column', 'Column', (['"""channel_id"""', 'BigInteger'], {'index': '(True)', 'nullable': '(False)'}), "('channel_id', BigInteger, index=True, nullable=False)\n", (794, 848), False, 'from sqlmodel import BigInteger, Column, DateTime, Field, ForeignKey, SQLModel\n'), ((669, 696), 'sqlmodel.ForeignKey', 'ForeignKey', (['"""users.user_id"""'], {}), "('users.user_id')\n", (679, 696), False, 'from sqlmodel import BigInteger, Column, DateTime, Field, ForeignKey, SQLModel\n'), ((993, 1016), 'sqlmodel.DateTime', 'DateTime', ([], {'timezone': '(True)'}), '(timezone=True)\n', (1001, 1016), False, 'from sqlmodel import BigInteger, Column, DateTime, Field, ForeignKey, SQLModel\n'), ((1151, 1174), 'sqlmodel.DateTime', 'DateTime', ([], {'timezone': '(True)'}), '(timezone=True)\n', (1159, 1174), False, 'from sqlmodel import BigInteger, Column, DateTime, Field, ForeignKey, SQLModel\n')]