"""Add Donation.currency

Revision ID: 258295832055
Revises: fc7f1504ed98
Create Date: 2024-08-13 10:47:52.704987

"""

import sqlalchemy as sa
from alembic import op

# Polar Custom Imports

# revision identifiers, used by Alembic.
revision = "258295832055"
down_revision = "fc7f1504ed98"
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(
        "donations", sa.Column("currency", sa.String(length=3), nullable=True)
    )

    op.execute(
        """
        UPDATE donations
        SET currency = 'usd'
    """
    )

    op.alter_column("donations", "currency", nullable=False, existing_nullable=True)

    # ### end Alembic commands ###


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