Skip to content
Back to skills

Php Migration Manager

ASecurity

Manages the full Laravel database migration lifecycle with safety checks and rollback planning (PHP analog of ef-/alembic-/sqlx-migration-manager). Covers create, review, apply, and rollback; enforces a reversible down(), expand-contract for zero-downtime changes, and guards against destructive operations in production. Use when creating or reviewing Laravel migrations, planning a schema change, applying/rolling back, or designing a zero-downtime migration.

  • 3 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 14, 2026
ai-agentsgophpbashsqlapidatabasesecurity

Works with

  • api

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned November 14, 2026

npx -y skills add michaelalber/ai-toolkit --skill php-migration-manager --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Php Migration Manager?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Php Migration Manager
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/michaelalber-php-migration-manager/badge)](https://www.skillsdirectory.com/skills/michaelalber-php-migration-manager)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: php-migration-manager
audience: team
description: >
  Manages the full Laravel database migration lifecycle with safety checks and rollback planning
  (PHP analog of ef-/alembic-/sqlx-migration-manager). Covers create, review, apply, and
  rollback; enforces a reversible down(), expand-contract for zero-downtime changes, and guards
  against destructive operations in production. Use when creating or reviewing Laravel
  migrations, planning a schema change, applying/rolling back, or designing a zero-downtime
  migration.
---

# PHP Migration Manager (Laravel)

> "A migration you cannot roll back is a deployment you cannot reverse."

> "Schema changes are the riskiest deploys you make. Treat them that way."

## Core Philosophy

Laravel migrations are version control for the database. This skill manages their full lifecycle —
**create → review → test rollback → apply → verify** — with safety gates between each step. A migration
is code that runs against production data exactly once per environment; a mistake is not a failed build,
it is corrupted or destroyed data.

The central discipline is **reversibility**. Every `up()` has a matching `down()` that returns the schema
to its prior state. The central risk is **destructive change on a live table**: dropping a column,
renaming, or adding a non-nullable column with no default while the old code still runs. For those, the
**expand-contract** pattern (a.k.a. parallel change) replaces a single dangerous migration with a safe
sequence across multiple deploys.

**Non-Negotiable Constraints:**
1. **Every `up()` has a tested `down()`** — rollback is verified, not assumed
2. **No destructive operation without expand-contract** on a table with live traffic
3. **`migrate:fresh` / `migrate:refresh` / `wipe` are forbidden against any shared or production DB**
4. **Review before apply** — a migration is read and risk-rated before `artisan migrate` runs
5. **Backfills are batched** — never one unbounded `UPDATE` on a large table
6. **Indexes on large tables are added concurrently** where the driver supports it

The full domain principles, knowledge-base lookups, and anti-pattern catalog live in
`references/domain-principles-and-anti-patterns.md`. The AI discipline rules and error-recovery
procedures live in `references/discipline-and-recovery.md`.

## Workflow

### Phase 1: CREATE

```bash
php artisan make:migration create_orders_table          # new table
php artisan make:migration add_phone_to_users_table     # alter
```

Write both `up()` and `down()`. Prefer additive, nullable changes. See
`references/migration-safety-checklist.md` for column-by-column guidance.

### Phase 2: REVIEW

Read the migration and risk-rate it **before** applying. Classify each operation as
SAFE / CAUTION / DANGEROUS using `references/dangerous-operations.md`. Produce the Migration Review
report (see `references/output-templates.md`). DANGEROUS operations require an expand-contract plan.

### Phase 3: TEST ROLLBACK

Apply and immediately roll back in a scratch database to prove `down()` works.

```bash
php artisan migrate --database=scratch
php artisan migrate:rollback --database=scratch --step=1
php artisan migrate:status --database=scratch
```

If `down()` errors or leaves residue, fix it before going further.

### Phase 4: APPLY

```bash
php artisan migrate --step          # records each migration separately for granular rollback
php artisan migrate:status
```

### Phase 5: VERIFY

Confirm the schema, run the backfill (batched), and re-run the app's test suite. Produce the
Post-Apply Verification report (see `references/output-templates.md`).

## State Block

```xml
<php-migration-manager-state>
  phase: CREATE | REVIEW | TEST_ROLLBACK | APPLY | VERIFY | COMPLETE
  migration: [migration file]
  laravel_version: [detected]
  operation_class: SAFE | CAUTION | DANGEROUS
  expand_contract_required: true | false
  down_method_present: true | false
  rollback_tested: true | false
  backfill_required: true | false
  applied: true | false
  last_action: [description]
</php-migration-manager-state>
```

## Output Template

Two reports drive the lifecycle gates; full markdown templates are in `references/output-templates.md`:

- **Migration Review** — operation(s), risk class, reversibility, findings table, rollback plan, and the
  apply/backfill/expand-contract decision. Produced in Phase 2 before any apply.
- **Post-Apply Verification** — a checklist confirming the migration ran, schema matches intent, batched
  backfill reconciled, tests green, rollback rehearsed, and no long lock observed. Produced in Phase 5.

## Integration with Other Skills

| Skill | Relationship |
|-------|-------------|
| `php-feature-slice` | A new slice that needs schema changes uses this skill for the migration lifecycle. |
| `php-architecture-checklist` | The checklist flags missing `down()` and direct-SQL risks this skill prevents. |
| `php-security-review` | Reviews migrations for unsafe raw SQL and over-broad grants. |
| `php-api-scaffolder` | When an endpoint needs new tables/columns, sequence the migration before shipping the route. |
| `tdd-loop` | Backfill logic and data transformations are driven test-first against a scratch database. |

Files in this skill

  • SKILL.md5.1 KB
  • references/dangerous-operations.md4.2 KB
  • references/discipline-and-recovery.md2.2 KB
  • references/domain-principles-and-anti-patterns.md4.5 KB
  • references/migration-safety-checklist.md4.3 KB
  • references/output-templates.md1.2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.