Indexes: Creating Indexes

$table->string('email')->unique();
$table->unique('email');
$table->index(['account_id', 'created_at']);
$table->unique('email', 'unique_email');

Available Index Types

  • $table->primary('id');.
  • $table->primary(['id', 'parent_id']);.
  • $table->unique('email');.
  • $table->index('state');.
  • $table->spatialIndex('location');.

Index Lengths & MySQL / MariaDB

Use Illuminate\Support\Facades\Schema;

/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot()
{
    Schema::defaultStringLength(191);
}

Indexes: Creating Indexes — Structure map

Clickable & Draggable!

Indexes: Creating Indexes — Related pages: