laravel-migrations
Laravel 13 database migrations - Schema Builder, columns, indexes, foreign keys, seeders, pgvector. Use when designing database schema or managing migrations.
What this skill does
# Laravel Migrations
## Agent Workflow (MANDATORY)
Before ANY implementation, use `TeamCreate` to spawn 3 agents:
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
| 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 |
---
## 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 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 |
### Foreign Key Cascade
| 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 |
---
## Reference Guide
### Core Concepts
| Topic | Reference | When to Consult |
|-------|-----------|-----------------|
| **Schema** | [schema.md](references/schema.md) | Table operations |
| **Columns** | [columns.md](references/columns.md) | Column types |
| **Indexes** | [indexes.md](references/indexes.md) | Performance indexes |
| **Foreign Keys** | [foreign-keys.md](references/foreign-keys.md) | Constraints |
| **Commands** | [commands.md](references/commands.md) | Artisan commands |
| **Seeding** | [seeding.md](references/seeding.md) | Populate data |
### Advanced Topics
| Topic | Reference | When to Consult |
|-------|-----------|-----------------|
| **Testing** | [testing.md](references/testing.md) | Test migrations |
| **Production** | [production.md](references/production.md) | Deploy safely |
| **Troubleshooting** | [troubleshooting.md](references/troubleshooting.md) | Fix errors |
### Templates
| Template | When to Use |
|----------|-------------|
| [CreateTableMigration.php.md](references/templates/CreateTableMigration.php.md) | New table |
| [ModifyTableMigration.php.md](references/templates/ModifyTableMigration.php.md) | Alter table |
| [PivotTableMigration.php.md](references/templates/PivotTableMigration.php.md) | Many-to-many |
| [Seeder.php.md](references/templates/Seeder.php.md) | Seed patterns |
| [MigrationTest.php.md](references/templates/MigrationTest.php.md) | Test migrations |
---
## Quick Reference
### Create Table
```php
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
```php
Schema::table('posts', function (Blueprint $table) {
$table->string('slug')->after('title')->unique();
$table->boolean('featured')->default(false);
});
```
### Commands
```bash
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.
```php
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()`.
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.