plugins/laravel-expert/skills/laravel-migrations/SKILL.md
Laravel 13 database migrations - Schema Builder, columns, indexes, foreign keys, seeders, pgvector. Use when designing database schema or managing migrations.
npx skillsauth add fusengine/agents laravel-migrationsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Before ANY implementation, use TeamCreate to spawn 3 agents:
After implementation, run fuse-ai-pilot:sniper for validation.
| Feature | Description | |---------|-------------| | Schema Builder | Create, modify, drop tables | | Columns | 50+ column types with modifiers | | Indexes | Primary, unique, fulltext, spatial | | Foreign Keys | Constraints with cascade options | | Seeders | Populate tables with data |
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
| Use Case | Type | Example |
|----------|------|---------|
| Primary Key | id() | Auto-increment BIGINT |
| Foreign Key | foreignId()->constrained() | References parent |
| UUID Primary | uuid()->primary() | UUIDs |
| Boolean | boolean() | is_active |
| Enum | enum('status', [...]) | order_status |
| JSON | json() | preferences |
| Money | decimal('price', 10, 2) | 99999999.99 |
| Timestamps | timestamps() | created_at, updated_at |
| Soft Delete | softDeletes() | deleted_at |
| Scenario | onDelete | Use Case |
|----------|----------|----------|
| Strict integrity | restrictOnDelete() | Financial records |
| Auto-cleanup | cascadeOnDelete() | Post → Comments |
| Preserve with null | nullOnDelete() | Optional relations |
| No action | noActionOnDelete() | Audit logs |
| Topic | Reference | When to Consult | |-------|-----------|-----------------| | Schema | schema.md | Table operations | | Columns | columns.md | Column types | | Indexes | indexes.md | Performance indexes | | Foreign Keys | foreign-keys.md | Constraints | | Commands | commands.md | Artisan commands | | Seeding | seeding.md | Populate data |
| Topic | Reference | When to Consult | |-------|-----------|-----------------| | Testing | testing.md | Test migrations | | Production | production.md | Deploy safely | | Troubleshooting | troubleshooting.md | Fix errors |
| Template | When to Use | |----------|-------------| | CreateTableMigration.php.md | New table | | ModifyTableMigration.php.md | Alter table | | PivotTableMigration.php.md | Many-to-many | | Seeder.php.md | Seed patterns | | MigrationTest.php.md | Test migrations |
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']);
});
Schema::table('posts', function (Blueprint $table) {
$table->string('slug')->after('title')->unique();
$table->boolean('featured')->default(false);
});
php artisan make:migration create_posts_table
php artisan migrate
php artisan migrate:rollback --step=1
php artisan migrate:fresh --seed
foreignId()->constrained() for foreign keys--pretend to preview SQLLaravel 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().
development
Use when optimizing entity-based / semantic SEO 2026. Covers entity maps, Google Knowledge Graph resolution, salience scoring, passage-level ranking, about/sameAs/knowsAbout schema, Cloud Natural Language API validation.
development
Use when running SEO, GEO, schema, Core Web Vitals, sitemap, hreflang, E-E-A-T, AI Overviews, technical SEO, or structured data tasks. Covers full-site audits, single-page analysis, schema markup, content quality, AI search optimization, local SEO, sitemap/robots, internal linking, semantic clustering, and search experience.
development
Use when optimizing search experience (SXO). Covers intent matching, user personas, user stories, page-type analysis, dwell time, scroll depth, pogo-sticking prevention.
development
Use when optimizing local SEO. Covers Google Business Profile, NAP consistency, citations, reviews acquisition, Local Pack ranking, location pages, LocalBusiness schema.