Backend Migrations

Create reversible Laravel migrations for database schema changes.

Updated Oct 31, 2025
One-click install
npx skills add https://github.com/FlorianRiquelme/statamic-assets --skill backend-migrations-florianriquelme
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Backend Migrations
Source: https://github.com/FlorianRiquelme/statamic-assets/tree/main/.claude/skills/backend-migrations
Command: npx skills add https://github.com/FlorianRiquelme/statamic-assets --skill backend-migrations-florianriquelme

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill ensures your database schema changes are robust, reversible, and follow best practices, preventing common issues like data loss or deployment failures. It guides the AI to create migrations that are safe and maintainable.

Core Features & Use Cases

  • Reversible Changes: Guarantees up() and down() methods for safe rollbacks and forward-compatible deployments.
  • Schema Integrity: Manages indexes, foreign key constraints, and column modifications with precision.
  • Use Case: When adding a new users.email_verified_at column, this skill ensures the migration is reversible, properly indexed, and follows Laravel conventions for zero-downtime deployments.

Quick Start

Generate a Laravel migration to add a 'status' column to the 'orders' table, ensuring it's reversible and indexed.

Frequently Asked Questions about Backend Migrations

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

FAQPage Schema
How do I create reversible database migrations in Laravel?

Reversible Laravel migrations require both up() and down() methods that mirror each other. The up() method applies schema changes (create tables, add columns, create indexes), while down() precisely reverses them. This ensures safe rollbacks and forward compatibility across deployments.

What's the best way to handle zero-downtime database schema changes?

Zero-downtime deployments separate schema changes from data migrations and ensure backwards compatibility. Add new columns with defaults before removing old ones, deploy code that handles both states, then remove deprecated columns in a follow-up migration. This prevents application errors during the transition.

How do I safely add indexes and foreign keys to existing tables?

Add indexes and foreign key constraints in dedicated migrations after verifying data integrity. Index new columns to improve query performance, and define foreign keys with appropriate cascade rules. Keep these changes separate from column additions for clarity and easier rollback.

Can I rename tables and columns safely in Laravel migrations?

Rename operations are reversible in Laravel migrations using the rename() method for columns and renaming for tables. Ensure the down() method renames them back to original names. Plan renames during low-traffic periods and coordinate with code deployments to avoid application errors.

Why should database schema changes be single-purpose?

Single-purpose migrations isolate changes logically, making rollbacks precise and easier to debug. If one change fails, you can revert just that migration without affecting unrelated schema modifications. This approach also simplifies reviewing deployment history and coordinating team deployments.

Do I need to separate data migrations from schema migrations?

Yes, separating data migrations from schema changes improves safety and clarity. Apply schema changes first (tables, columns, indexes), then perform data transformations in subsequent migrations. This prevents data loss and makes each migration's purpose explicit and reversible.