All challengesCHALLENGE 17 OF 25

Fix Unsafe Migration Instructions

Make database migrations safe to apply and roll back.

Advanced

Goal

Protect database migration history and make schema changes safe for environments where previous migrations may already have been applied.

Repository Context

This production application uses PostgreSQL migrations.

Code exampleMarkdown
platform-api/
├── src/
├── migrations/
│   ├── 001_create_users.sql
│   ├── 002_create_organizations.sql
│   └── 003_add_memberships.sql
├── package.json
└── AGENTS.md

Committed migrations may already have been applied in staging or production.

The repository follows these rules:

  • Previously applied migration files must not be rewritten to introduce new schema changes.
  • New schema changes require a new migration.
  • Migrations should be reviewed for compatibility with existing data.
  • Destructive changes require an explicit migration strategy rather than assuming existing data can be discarded.

Current AGENTS.md

Code exampleMarkdown
# Project Instructions

## Database

- Keep migrations in `migrations/`.
- When the schema changes, edit the most recent migration so the migration history stays small.
- If an existing column is no longer needed, drop it immediately without considering existing data.

## Validation

- Run database tests after changing the schema.

Your Task

Repair the migration instructions.

Preserve previously applied migration history, require new migrations for new schema changes, and make destructive schema changes account for existing data.

YOUR AGENTS.mdEdit the Current AGENTS.md shown in the challenge
AGENTS.mdMarkdown
Loading editor…

Sign in to save progress across devices.

Your answer is checked locally against the challenge rules. No AI is used for evaluation.