for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
use yii\db\Migration;
use yii\rbac\DbManager;
use yii\base\InvalidConfigException;
* Adds index on `user_id` column in `auth_assignment` table for performance reasons.
*
* @see https://github.com/yiisoft/yii2/pull/14765
* @author Ivan Buttinoni <[email protected]>
* @since 2.0.13
class m170907_052038_rbac_add_index_on_auth_assignment_user_id extends Migration
{
public $column = 'user_id';
public $index = 'auth_assignment_user_id_idx';
* @throws yii\base\InvalidConfigException
* @return DbManager
protected function getAuthManager()
$authManager = Yii::$app->getAuthManager();
if (!$authManager instanceof DbManager) {
throw new InvalidConfigException('You should configure "authManager" component to use database before executing this migration.');
}
return $authManager;
* @inheritdoc
public function up()
$authManager = $this->getAuthManager();
$this->createIndex($this->index, $authManager->assignmentTable, $this->column);
public function down()
$this->dropIndex($this->index, $authManager->assignmentTable);