"""Add API integration keys to UserSetting

Revision ID: fa0c5e3262d5
Revises: 44f7e10ef777
Create Date: 2026-02-23 14:25:45.021512

"""
from collections.abc import Sequence

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = 'fa0c5e3262d5'
down_revision: str | Sequence[str] | None = '44f7e10ef777'
branch_labels: str | Sequence[str] | None = None
depends_on: str | Sequence[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f('ix_publications_doi'), table_name='publications')
    op.drop_column('publications', 'doi')
    op.add_column('user_settings', sa.Column('openalex_api_key', sa.String(length=255), nullable=True))
    op.add_column('user_settings', sa.Column('crossref_api_token', sa.String(length=255), nullable=True))
    op.add_column('user_settings', sa.Column('crossref_api_mailto', sa.String(length=255), nullable=True))
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('user_settings', 'crossref_api_mailto')
    op.drop_column('user_settings', 'crossref_api_token')
    op.drop_column('user_settings', 'openalex_api_key')
    op.add_column('publications', sa.Column('doi', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
    op.create_index(op.f('ix_publications_doi'), 'publications', ['doi'], unique=False)
    # ### end Alembic commands ###

