"""Add Pledge.currency

Revision ID: 6ee98bd21641
Revises: 258295832055
Create Date: 2024-08-13 11:14:04.601923

"""

import sqlalchemy as sa
from alembic import op

# Polar Custom Imports

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

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

    op.alter_column("pledges", "currency", nullable=False, existing_nullable=True)
    # ### end Alembic commands ###


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