"""expire and fingerprintjs token

Revision ID: 5821f37941a8
Revises: b879d3502c37
Create Date: 2025-09-21 20:16:48.289050

"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "5821f37941a8"
down_revision: Union[str, None] = "b879d3502c37"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
    """Upgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "refresh_tokens",
        sa.Column("fingerprint", sa.String(length=255), nullable=False),
    )
    op.add_column(
        "refresh_tokens",
        sa.Column(
            "expired_at",
            sa.TIMESTAMP(timezone=True),
            server_default=sa.text("(datetime('now', '+7 days'))"),
            nullable=False,
        ),
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade schema."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("refresh_tokens", "expired_at")
    op.drop_column("refresh_tokens", "fingerprint")
    # ### end Alembic commands ###
