# -*- coding: utf-8 -*-
#
# Copyright (C) 2016-2018 CERN.
# Copyright (C) 2025-2026 Graz University of Technology.
#
# invenio-edugain is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.

"""Update edugain_idp_data table."""

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision = "1764593266"
down_revision = "1742382925"
branch_labels = ()
depends_on = None


def upgrade() -> None:
    """Upgrade database."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "edugain_idp_data",
        sa.Column(
            "discoverable",
            sa.Boolean(),
            nullable=False,
            default=True,
            server_default=sa.sql.expression.literal(True),  # noqa: FBT003
        ),
    )
    op.drop_column("edugain_idp_data", "logo_url")
    op.drop_column("edugain_idp_data", "displayname")
    # ### end Alembic commands ###


def downgrade() -> None:
    """Downgrade database."""
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "edugain_idp_data",
        sa.Column("displayname", sa.VARCHAR(), autoincrement=False, nullable=False),
    )
    op.add_column(
        "edugain_idp_data",
        sa.Column("logo_url", sa.VARCHAR(), autoincrement=False, nullable=False),
    )
    op.drop_column("edugain_idp_data", "discoverable")
    # ### end Alembic commands ###
