Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
create-database-migration
create-database-migration
alizharb/agent-skills
claude-code
migrations
eloquent
schema-design
database-constraints
indexes
rollbacks

Use when creating, altering, or adding new database tables, indexes, or constraints in Laravel migrations.

Install
php artisan boost:add-skill alizharb/agent-skills

Save this content to: .claude/skills/create-database-migration/SKILL.md

# Create Database Migration

## When To Use

Use this skill when designing schemas, creating new Eloquent model backing tables, adding indexes, or modifying existing database columns.

## Workflow

1. **Verify conventions**: Inspect nearby migration files to ensure naming compatibility.
2. **Scaffold migration**: Run `php artisan make:migration create_xxx_table`.
3. **Define constraints**: Declare explicit relationships, types, indexes, and unique attributes.
4. **Define down operation**: Ensure the migration is reversible (implement `down()` properly dropping added columns or tables).
5. **Dry run checks**: Run local migrations and rollbacks to verify structural success.

## Examples

### Good Example

```php
// database/migrations/2026_07_07_000000_create_profiles_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('profiles', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->unique()->constrained()->cascadeOnDelete();
            $table->string('bio', 500)->nullable();
            $table->string('avatar_url')->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('profiles');
    }
};
```

### Bad Example

```php
// ❌ Creating relations without constraints, missing indices, missing down method.
Schema::create('profiles', function (Blueprint $table) {
    $table->id();
    $table->integer('user_id'); // Vulnerable and loose relation!
    $table->text('bio');
});
```

Create Database Migration

When To Use

Use this skill when designing schemas, creating new Eloquent model backing tables, adding indexes, or modifying existing database columns.

Workflow

  1. Verify conventions: Inspect nearby migration files to ensure naming compatibility.
  2. Scaffold migration: Run php artisan make:migration create_xxx_table.
  3. Define constraints: Declare explicit relationships, types, indexes, and unique attributes.
  4. Define down operation: Ensure the migration is reversible (implement down() properly dropping added columns or tables).
  5. Dry run checks: Run local migrations and rollbacks to verify structural success.

Examples

Good Example

// database/migrations/2026_07_07_000000_create_profiles_table.php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('profiles', function (Blueprint $table) {
            $table->id();
            $table->foreignId('user_id')->unique()->constrained()->cascadeOnDelete();
            $table->string('bio', 500)->nullable();
            $table->string('avatar_url')->nullable();
            $table->timestamps();
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('profiles');
    }
};

Bad Example

// ❌ Creating relations without constraints, missing indices, missing down method.
Schema::create('profiles', function (Blueprint $table) {
    $table->id();
    $table->integer('user_id'); // Vulnerable and loose relation!
    $table->text('bio');
});
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console