Keep schema changes safe, testable, and reversible.
Commands
php artisan make:model Post -mfc
# Run/rollback
php artisan migrate
php artisan migrate:rollback --step=1
# Fresh DB (dangerous; dev only)
php artisan migrate:fresh --seed
Rules
Pair each new model with a migration and a factory
If a migration was merged to main, never edit it—add a new one
On feature branches, you may amend migrations created on that branch (if not merged)
Seed realistic but minimal datasets in seeder classes; keep huge datasets external
Factories
Prefer state modifiers (e.g., ->state([...])) over boolean flags
Use relationships (e.g., belongsTo) in factories to build realistic graphs
Keep factories fast; move expensive setup to seeds where possible
Testing
Use factories in tests; avoid manual inserts
For integration tests touching DB, use transactions or RefreshDatabase
1---2name: laravel-migrations-and-factories3description: Migrations and Factories4---5# Migrations and Factories67Keep schema changes safe, testable, and reversible.89## Commands1011```12php artisan make:model Post -mfc1314# Run/rollback15php artisan migrate16php artisan migrate:rollback --step=11718# Fresh DB (dangerous; dev only)19php artisan migrate:fresh --seed20```2122## Rules2324- Pair each new model with a migration and a factory25- If a migration was merged to `main`, never edit it—add a new one26- On feature branches, you may amend migrations created on that branch (if not merged)27- Seed realistic but minimal datasets in seeder classes; keep huge datasets external2829## Factories3031- Prefer state modifiers (e.g., `->state([...])`) over boolean flags32- Use relationships (e.g., `belongsTo`) in factories to build realistic graphs33- Keep factories fast; move expensive setup to seeds where possible3435## Testing3637- Use factories in tests; avoid manual inserts38- For integration tests touching DB, use transactions or `RefreshDatabase`
Run npx skillmds@latest add comeonoliver/laravel-migrations-and-factories in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
Migrations and Factories It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. Independent scanners report: SkillSpector: PASS, Skill Scanner: PASS. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
ComeOnOliver (@comeonoliver) published this skill. Their other Agent Skills are listed on their SkillMD profile.