"""Add WebhookEndpoint.format

Revision ID: 3981cdd5db56
Revises: 6ee98bd21641
Create Date: 2024-08-13 17:10:47.952745

"""

import sqlalchemy as sa
from alembic import op

# Polar Custom Imports

# revision identifiers, used by Alembic.
revision = "3981cdd5db56"
down_revision = "6ee98bd21641"
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("webhook_endpoints", sa.Column("format", sa.String(), nullable=True))

    op.execute("UPDATE webhook_endpoints SET format = 'raw'")

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


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