"""Add OAuthClient.first_party

Revision ID: 613163140f90
Revises: aa7611c80a41
Create Date: 2025-12-11 13:37:20.080658

"""

import sqlalchemy as sa
from alembic import op

# Polar Custom Imports

# revision identifiers, used by Alembic.
revision = "613163140f90"
down_revision = "aa7611c80a41"
branch_labels: tuple[str] | None = None
depends_on: tuple[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.add_column(
        "oauth2_clients", sa.Column("first_party", sa.Boolean(), nullable=True)
    )
    op.execute(
        "UPDATE oauth2_clients SET first_party = FALSE WHERE first_party IS NULL"
    )
    op.alter_column(
        "oauth2_clients", "first_party", existing_type=sa.Boolean(), nullable=False
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_column("oauth2_clients", "first_party")
    # ### end Alembic commands ###
