"""add session_version to users and key_fingerprint to user_api_keys

Revision ID: 7ebe3a12f343
Revises: bf7ed6db5eff
Create Date: 2026-04-30 17:43:25.041836

"""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "7ebe3a12f343"
down_revision = "bf7ed6db5eff"
branch_labels = None
depends_on = None


def upgrade() -> None:
  # ### commands auto generated by Alembic - please adjust! ###
  op.add_column(
    "user_api_keys", sa.Column("key_fingerprint", sa.String(length=64), nullable=True)
  )
  op.create_index(
    op.f("ix_user_api_keys_key_fingerprint"),
    "user_api_keys",
    ["key_fingerprint"],
    unique=True,
  )
  op.add_column(
    "users",
    sa.Column("session_version", sa.Integer(), server_default="0", nullable=False),
  )
  # ### end Alembic commands ###


def downgrade() -> None:
  # ### commands auto generated by Alembic - please adjust! ###
  op.drop_column("users", "session_version")
  op.drop_index(op.f("ix_user_api_keys_key_fingerprint"), table_name="user_api_keys")
  op.drop_column("user_api_keys", "key_fingerprint")
  # ### end Alembic commands ###
