"""Allow multiple null inside member.external_id

Revision ID: 827dddaa615a
Revises: 613163140f90
Create Date: 2025-12-11 14:43:07.293389

"""

import sqlalchemy as sa
from alembic import op

# Polar Custom Imports

# revision identifiers, used by Alembic.
revision = "827dddaa615a"
down_revision = "613163140f90"
branch_labels: tuple[str] | None = None
depends_on: tuple[str] | None = None


def upgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint(
        op.f("members_customer_id_external_id_key"), "members", type_="unique"
    )
    op.create_unique_constraint(
        "members_customer_id_external_id_key",
        "members",
        ["customer_id", "external_id"],
        postgresql_nulls_not_distinct=False,
    )
    # ### end Alembic commands ###


def downgrade() -> None:
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_constraint("members_customer_id_external_id_key", "members", type_="unique")
    op.create_unique_constraint(
        op.f("members_customer_id_external_id_key"),
        "members",
        ["customer_id", "external_id"],
        postgresql_nulls_not_distinct=True,
    )
    # ### end Alembic commands ###
