Migrations

Manage your database schema with code.

CLI Commands

terminal
./ief migrate
./ief migrate:rollback
./ief migrate:fresh
./ief make:migration create_posts_table

Example

app/Migrations/CreatePostsTable.php
class CreatePostsTable extends Migration
{
    public function up(): void
    {
        $this->schema()->create('posts', function ($table) {
            $table->uuid('id')->primary();
            $table->string('title');
            $table->text('body');
            $table->foreignId('user_id');
            $table->boolean('published')->default(false);
            $table->timestamps();
        });
    }

    public function down(): void
    {
        $this->schema()->drop('posts');
    }
}