"""Drop unique constraint on addons_customers.id_customer.

Multiple customer hashes can map to the same id_customer.
Uses batch mode to recreate the table for SQLite compatibility.

Revision ID: w4x5y6z7a8b9
Revises: v3w4x5y6z7a8
Create Date: 2026-03-16
"""
from alembic import op
import sqlalchemy as sa

revision = 'w4x5y6z7a8b9'
down_revision = 'v3w4x5y6z7a8'
branch_labels = None
depends_on = None


def upgrade():
    # Recreate table: id_customer changes from UNIQUE to indexed (non-unique)
    with op.batch_alter_table('addons_customers', recreate='always') as batch_op:
        batch_op.alter_column('id_customer', existing_type=sa.Integer(),
                              existing_nullable=True)
        batch_op.create_index('ix_addons_customers_id_customer', ['id_customer'])


def downgrade():
    with op.batch_alter_table('addons_customers', recreate='always') as batch_op:
        batch_op.drop_index('ix_addons_customers_id_customer')
