# Write a reversible migration and exercise the rollback

A migration with a rollback that has actually been run, not just written.

Category: Data layer and migrations
Source: https://letsship.ai/use-cases/write-a-reversible-migration
Published: 2026-08-25

## Goal

Write a migration with a working rollback and exercise both directions in CI.

## Acceptance criteria

- The migration runs forward and back against a seeded database in CI
- The rollback restores the previous schema exactly
- Data loss on rollback is stated explicitly if it is unavoidable
- Both directions are idempotent enough to re-run safely

## What lands as proof

A CI run that applies and reverts the migration, which is the only way to know the rollback works.

## 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: Make the {migration} migration reversible

Description: Write a migration with a working rollback and exercise both directions in CI.

Acceptance criteria:
- The migration runs forward and back against a seeded database in CI
- The rollback restores the previous schema exactly
- Data loss on rollback is stated explicitly if it is unavoidable
- Both directions are idempotent enough to re-run safely

Before you create the issue, check whether this repository's migrations have tested down paths and replace {migration} with a recent one that does not.
```

## Questions

### What does the agent actually change?

The ticket is scoped to one outcome: write a migration with a working rollback and exercise both directions in CI. 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 up and down both run in CI against a seeded database, so a reviewer can confirm the result without reproducing the work locally.

### How much oversight does this need?

The run stops once the plan is written. Somebody reads the approach and approves it before any code exists, which is the cheapest moment to redirect the work.
