LoginSignup
26
19

More than 5 years have passed since last update.

Laravel のマイグレーションで複合インデックスにしつつインデックス名を指定する方法

Last updated at Posted at 2016-12-21

環境

  • CentOS 7
  • PHP 7
  • Laravel 5.3
  • MySQL 5.7

複合インデックスにしつつインデックス名を指定する方法

  • 第一引数を配列にすればできる

    $table->index(['カラム名1', 'カラム名2'], 'インデックス名')

  • ユニークキーも同じようにできる

    $table->unique(['カラム名1', 'カラム名2'], 'ユニークキー名');

通常インデックス作成方法

$table->index('カラム名');

複合インデックス作成方法

$table->index(['カラム名1', 'カラム名2']);

インデックス名を指定する方法

$table->index('カラム名', 'インデックス名');

26
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
26
19