<!-- Source: @site/projects/sqlens-for-laravel/docs/rules/deploy-legacy-invalid-index-name-collision.md -->
<!-- Canonical: https://docs.pushery.com/sqlens-for-laravel/rules/deploy-legacy-invalid-index-name-collision/ -->

# DEPLOY.LEGACY.INVALID_INDEX_NAME_COLLISION — an invalid index is standing where this deploy wants to build one

> The same wreckage as a plain invalid index, except the migration about to run will fail on the name.

- **Category:** safety
- **Severity:** high
- **Level:** 0
- **Downtime class:** online
- **Stability:** stable
- **Suites:** deploy
- **Applies to:** PostgreSQL

## Debt, or a deploy that ends halfway

[DEPLOY.LEGACY.INVALID_INDEX](https://docs.pushery.com/sqlens-for-laravel/rules/deploy-legacy-invalid-index.md) reports an index left invalid by a
build that did not finish. That is debt: real, worth clearing, survivable for another week.

This is the same wreckage with one difference that changes everything — **the pending migration
re-uses its name**. `CREATE INDEX` will fail on a name conflict, the deploy ends partway through, and
the error nobody reads as a name conflict is the one you get.

That is not a matter of degree, which is why it is its own id rather than a louder severity.

## What to do about it

```sql
-- The leftover is not usable: the planner ignores it while it still costs write amplification.
DROP INDEX CONCURRENTLY "public"."idx_orders_status";
```

Then re-run the deploy. `CONCURRENTLY` keeps the drop off the table's write path.

## The cases this cannot see

- It matches on the index **name** the pending migration uses. A build that reaches the same object
  under a different name collides at run time and is not anticipated here.
- It cannot tell an index that is **mid-build** from one whose build **failed** — both read
  `indisvalid = false` while they exist, and only the second is wreckage.
