# Laravel:migrations And Factories

> Safe database change patterns; when to modify vs add migrations; always pair models with migrations and factories; seeding guidance

- **Type:** Skill
- **Install:** `agentstack add skill-jpcaparas-superpowers-laravel-migrations-and-factories`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [jpcaparas](https://agentstack.voostack.com/s/jpcaparas)
- **Installs:** 0
- **Category:** [Databases](https://agentstack.voostack.com/c/databases)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [jpcaparas](https://github.com/jpcaparas)
- **Source:** https://github.com/jpcaparas/superpowers-laravel/tree/main/skills/migrations-and-factories

## Install

```sh
agentstack add skill-jpcaparas-superpowers-laravel-migrations-and-factories
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Migrations and Factories

Keep schema changes safe, testable, and reversible.

## Commands

```
# Create model with migration + factory
sail artisan make:model Post -mfc   # or: php artisan make:model Post -mfc

# Run/rollback
sail artisan migrate                # or: php artisan migrate
sail artisan migrate:rollback --step=1   # or: php artisan migrate:rollback --step=1

# Fresh DB (dangerous; dev only)
sail artisan migrate:fresh --seed   # or: 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`

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [jpcaparas](https://github.com/jpcaparas)
- **Source:** [jpcaparas/superpowers-laravel](https://github.com/jpcaparas/superpowers-laravel)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-jpcaparas-superpowers-laravel-migrations-and-factories
- Seller: https://agentstack.voostack.com/s/jpcaparas
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
