# Add the unique constraint a duplicate-row bug keeps proving is missing

A duplicate-row bug fixed at the schema rather than in the application for the fourth time.

Category: Data layer and migrations
Source: https://letsship.ai/use-cases/add-the-unique-constraint
Published: 2026-08-25

## Goal

Add the unique constraint that prevents a recurring duplicate-row bug.

## Acceptance criteria

- Existing duplicates are reported and resolved before the constraint is added
- The resolution rule for duplicates is agreed and recorded
- The constraint is added without an unacceptable lock
- A test asserts a duplicate insert is now refused

## What lands as proof

The duplicate report, the resolution, and a test proving the second insert is refused.

## Prompt

Copy this to an agent to open the ticket:

```text
Create a Linear issue in my team and assign it to the SHIP agent.

Title: Add a unique constraint on {columns}

Description: Add the unique constraint that prevents a recurring duplicate-row bug.

Acceptance criteria:
- Existing duplicates are reported and resolved before the constraint is added
- The resolution rule for duplicates is agreed and recorded
- The constraint is added without an unacceptable lock
- A test asserts a duplicate insert is now refused

Before you create the issue, find the recurring duplicate-row bug in this repository and replace {columns} with the columns that should be unique.
```

## Questions

### What does the agent actually change?

The ticket is scoped to one outcome: add the unique constraint that prevents a recurring duplicate-row bug. Work that serves that outcome is in scope, and anything outside it is left for a separate ticket, so the pull request stays reviewable.

### How do I know the work is done?

The pull request carries the evidence, not only the diff. Here that means duplicates reported and resolved first, then the constraint holds, so a reviewer can confirm the result without reproducing the work locally.

### How much oversight does this need?

The run stops for the plan, and the review bar is raised afterwards so that smaller suggestions block the merge too, not only serious findings.
