agentleFS
michaelalbermichaelalber/ai-toolkit/skills/php-migration-manager/SKILL.md

php-migration-manager

Skill3 starsChanged 3 months agoMITView on GitHub

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.

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Write both up() and down().

    line 53
  2. Very specific:

    Read the migration and risk-rate it before applying.

    line 58
  3. Very specific:

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

    line 72

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

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.

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

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

<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

SkillRelationship
php-feature-sliceA new slice that needs schema changes uses this skill for the migration lifecycle.
php-architecture-checklistThe checklist flags missing down() and direct-SQL risks this skill prevents.
php-security-reviewReviews migrations for unsafe raw SQL and over-broad grants.
php-api-scaffolderWhen an endpoint needs new tables/columns, sequence the migration before shipping the route.
tdd-loopBackfill logic and data transformations are driven test-first against a scratch database.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.