"""Add Subscription.tax_exempted

Revision ID: 503b06c92be0
Revises: da0275629643
Create Date: 2025-08-21 09:59:30.878476

"""

import sqlalchemy as sa
from alembic import op

# Polar Custom Imports

# revision identifiers, used by Alembic.
revision = "503b06c92be0"
down_revision = "da0275629643"
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(
        "subscriptions", sa.Column("tax_exempted", sa.Boolean(), nullable=True)
    )
    op.execute(
        "UPDATE subscriptions SET tax_exempted = FALSE WHERE tax_exempted IS NULL"
    )
    op.alter_column(
        "subscriptions",
        "tax_exempted",
        existing_type=sa.Boolean(),
        nullable=False,
        existing_nullable=True,
    )
    # ### end Alembic commands ###


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