> ## Documentation Index
> Fetch the complete documentation index at: https://loadwise.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# migration-constraint-without-index

> A unique or primary key constraint builds its index while blocking writes.

## What it flags

Adding a PostgreSQL `UNIQUE` or `PRIMARY KEY` constraint to an existing table without attaching an existing index with `USING INDEX`. The index build blocks reads and writes. This includes an inline `ADD COLUMN ... UNIQUE` constraint.

For an inline constraint, add the column without `UNIQUE` first. Review a separate concurrent unique index build outside a transaction, then attach the index where PostgreSQL supports it. The staged change needs manual review.

## Configuration

Set the rule to `"off"` in `loadwise.config.json` to drop its findings:

```json theme={null}
{
  "rules": { "migration-constraint-without-index": "off" }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.