laravel-migrations

SkillDatabases & data

Use when designing a database schema or managing Laravel 13 migrations — Schema Builder, columns, indexes, foreign keys, or seeders.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the laravel-migrations skill

What this skill tells your AI

The instructions your AI receives, as published by fusengine/agents in plugins/laravel-expert/skills/laravel-migrations/SKILL.md and read by ahel’s review.

Laravel Migrations

Agent Workflow (MANDATORY)

Before ANY implementation, spawn 3 agents in parallel, one Agent call each with a name:

  1. fuse-ai-pilot:explore-codebase - Check existing migrations
  2. fuse-ai-pilot:research-expert - Verify Laravel 13 patterns via Context7
  3. mcp__context7__query-docs - Check specific Schema Builder features

After implementation, run fuse-ai-pilot:sniper for validation.


Overview

FeatureDescription
Schema BuilderCreate, modify, drop tables
Columns50+ column types with modifiers
IndexesPrimary, unique, fulltext, spatial
Foreign KeysConstraints with cascade options
SeedersPopulate tables with data

Critical Rules

  1. Always define down() - Reversible migrations
  2. Use foreignId()->constrained() - Not raw unsignedBigInteger
  3. Add indexes on foreign keys - Performance critical
  4. Test rollback before deploy - Validate down() works
  5. Never modify deployed migrations - Create new ones

Decision Guide

Migration Type

Need schema change?
├── New table → make:migration create_X_table
├── Add column → make:migration add_X_to_Y_table
├── Modify column → make:migration modify_X_in_Y_table
├── Add index → make:migration add_index_to_Y_table
└── Seed data → make:seeder XSeeder

Column Type Selection

Use CaseTypeExample
Primary Keyid()Auto-increment BIGINT
Foreign KeyforeignId()->constrained()References parent
UUID Primaryuuid()->primary()UUIDs
Booleanboolean()is_active
Enumenum('status', [...])order_status
JSONjson()preferences
Moneydecimal('price', 10, 2)99999999.99
Timestampstimestamps()created_at, updated_at
Soft DeletesoftDeletes()deleted_at

Foreign Key Cascade

ScenarioonDeleteUse Case
Strict integrityrestrictOnDelete()Financial records
Auto-cleanupcascadeOnDelete()Post → Comments
Preserve with nullnullOnDelete()Optional relations
No actionnoActionOnDelete()Audit logs

Reference Guide

Core Concepts

TopicReferenceWhen to Consult
Schemaschema.mdTable operations
Columnscolumns.mdColumn types
Indexesindexes.mdPerformance indexes
Foreign Keysforeign-keys.mdConstraints
Commandscommands.mdArtisan commands
Seedingseeding.mdPopulate data

Advanced Topics

TopicReferenceWhen to Consult
Testingtesting.mdTest migrations
Productionproduction.mdDeploy safely
Troubleshootingtroubleshooting.mdFix errors

Templates

TemplateWhen to Use
CreateTableMigration.php.mdNew table
ModifyTableMigration.php.mdAlter table
PivotTableMigration.php.mdMany-to-many
Seeder.php.mdSeed patterns
MigrationTest.php.mdTest migrations

Quick Reference

Create Table

Schema::create('posts', function (Blueprint $table) {
    $table->id();
    $table->foreignId('user_id')->constrained()->cascadeOnDelete();
    $table->string('title');
    $table->text('content');
    $table->enum('status', ['draft', 'published'])->default('draft');
    $table->timestamps();
    $table->softDeletes();

    $table->index(['user_id', 'status']);
});

Modify Table

Schema::table('posts', function (Blueprint $table) {
    $table->string('slug')->after('title')->unique();
    $table->boolean('featured')->default(false);
});

Commands

php artisan make:migration create_posts_table
php artisan migrate
php artisan migrate:rollback --step=1
php artisan migrate:fresh --seed

Best Practices

DO

  • Use foreignId()->constrained() for foreign keys
  • Add composite indexes for common queries
  • Test down() method before deploying
  • Use --pretend to preview SQL

DON'T

  • Modify already-deployed migrations
  • Forget down() method
  • Use raw SQL without Schema Builder
  • Skip indexes on foreign keys

Laravel 13 Notes

Schema::ensureVectorExtensionExists() (pgvector)

Laravel 13 expose une helper pour activer l'extension pgvector sur PostgreSQL depuis une migration. Utile pour embeddings et recherche sémantique.

use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    public function up(): void
    {
        Schema::ensureVectorExtensionExists();

        Schema::create('documents', function (Blueprint $table) {
            $table->id();
            $table->text('content');
            $table->vector('embedding', dimensions: 1536); // OpenAI ada-002
            $table->timestamps();

            $table->index('embedding', 'documents_embedding_idx', 'hnsw');
        });
    }
};

Voir [[laravel-vector-search]] pour les requêtes whereVectorSimilarTo().

Signals

GitHub stars
25
Forks
4
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
laravel-migrations
Source
github.com/fusengine/agents