"""Update nav_tops unique constraint to include deleted_at"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '20251108_nav_tops_soft_delete'
down_revision = '20251108_soft_delete_all'
branch_labels = None
depends_on = None


def upgrade():
    
    # Drop existing constraint
    op.drop_constraint('uq_nav_tops_label_slug', 'nav_tops', type_='unique')

    # Add new constraint including deleted_at
    op.create_unique_constraint(
        'uq_nav_tops_label_slug',
        'nav_tops',
        ['label', 'slug', 'deleted_at']
    )


def downgrade():
    # Drop new constraint
    op.drop_constraint('uq_nav_tops_label_slug', 'nav_tops', type_='unique')

    # Restore old constraint
    op.create_unique_constraint(
        'uq_nav_tops_label_slug',
        'nav_tops',
        ['label', 'slug']
    )
