LoginSignup
1

More than 5 years have passed since last update.

CakePHP3のMigration時のインデックス名の付け方

Posted at

先に結論から書くと
$table->addIndex(['started','ended'], ['name' => 'started_ended']);
っと書けば付けれる。

CakePHP3のMigrationツールであるPhinxにおいて
インデックスを付ける場合
$table->addIndex('mail');
っと書くとmailというインデックス名でindex keyを作成してくれるが
$table->addIndex(['started','ended']);
っと書いた場合、インデックス名がstartedっとなって具合が悪かったので
インデックス名を付けたかった。

UNIQUE keyにする場合は
$table->addIndex(['email'], ['unique' => true, 'name' => 'uq_mail']);

参考
https://github.com/cakephp/phinx

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
1