0055-laravel-migrations-and-factories

Guide Laravel migration creation, rollback, and factory-based seeding workflows.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0055-laravel-migrations-and-factories
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: 0055-laravel-migrations-and-factories
Source: https://github.com/MrJmpl3/codex_____data_____configuration/tree/main/skills/0055-laravel-migrations-and-factories
Command: npx skills add https://github.com/MrJmpl3/codex_____data_____configuration --skill 0055-laravel-migrations-and-factories

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It prevents risky database edits by guiding you on when to create new migrations versus modifying existing ones, while keeping tests and seed data consistent through factories.

Core Features & Use Cases

  • Safe migration workflow: Learn to add new migrations instead of editing merged migrations, and use rollback or fresh workflows correctly.
  • Factory-driven model creation: Build realistic test data by pairing models with factories and using relationship-aware, state-based factory patterns.
  • Seeding and testing guidance: Create minimal yet realistic seed datasets and rely on factories for tests instead of manual inserts.

Quick Start

Generate a new Eloquent model with a paired migration and factory, then run migrations to apply the change safely.

Frequently Asked Questions about 0055-laravel-migrations-and-factories

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I safely modify a Laravel migration that has already been merged?▼

To ensure database safety with Laravel migrations, you should never edit a merged migration. Instead, create a new migration to alter the schema, keeping your database evolution reversible and preventing team conflicts.

What's the best way to create realistic test data in Laravel?▼

The best way to create realistic test data is using Laravel factories paired with your Eloquent models. Use state and relationship definitions within factories to generate deterministic datasets for integration testing.

When should I use factories instead of seeders in Laravel?▼

Use Laravel factories for generating deterministic test datasets during testing, and use seeders for minimal realistic base data. Rely on factories instead of manual inserts to keep tests isolated and consistent.

How do I maintain schema consistency across Laravel feature branches?▼

Maintain schema consistency by coupling Eloquent models with migrations and factories. Apply new migrations for branch changes and use rollback or fresh workflows to safely sync database states.

Should I use RefreshDatabase or transactions for Laravel integration tests?▼

You should favor RefreshDatabase or transactions for Laravel integration tests. These approaches reset the database state efficiently, ensuring factories generate clean data without persisting side effects.

Do I need to pair a factory every time I create an Eloquent model?▼

Yes, coupling Eloquent models with factories is required. This ensures you can instantly generate realistic test data using state and relationships whenever you add a new model and migration.