"""Make WebhookEvent.type non nullable

Revision ID: d96c81cf1e57
Revises: 8393207d3f0d
Create Date: 2025-09-10 14:57:26.844542

"""

import sqlalchemy as sa
from alembic import op

# Polar Custom Imports

# revision identifiers, used by Alembic.
revision = "d96c81cf1e57"
down_revision = "8393207d3f0d"
branch_labels: tuple[str] | None = None
depends_on: tuple[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.alter_column(
        "webhook_events", "type", existing_type=sa.VARCHAR(), nullable=False
    )
    with op.get_context().autocommit_block():
        op.create_index(
            op.f("ix_webhook_events_type"),
            "webhook_events",
            ["type"],
            unique=False,
            postgresql_concurrently=True,
        )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_index(op.f("ix_webhook_events_type"), table_name="webhook_events")
    op.alter_column("webhook_events", "type", existing_type=sa.VARCHAR(), nullable=True)
    # ### end Alembic commands ###
