Browse Source

Fixes #15548: Fixed index names collision in RBAC

tags/2.0.16
Sergey Gonimar 6 years ago committed by Alexander Makarov
parent
commit
9e6d5aa1a8
  1. 1
      framework/CHANGELOG.md
  2. 64
      framework/rbac/migrations/m180523_151638_rbac_updates_indexes_without_prefix.php

1
framework/CHANGELOG.md

@ -12,6 +12,7 @@ Yii Framework 2 Change Log
- Bug #14660: Fixed `yii\caching\DbCache` concurrency issue when set values with the same key (rugabarbo)
- Bug #15988: Fixed bash completion (alekciy)
- Bug #15798: Fixed render `yii\grid\RadioButtonColumn::$content` and `yii\grid\CheckboxColumn::$content` (lesha724)
- Bug #15548: Fixed index names collision in RBAC (gonimar)
- Bug #15117: Fixed `yii\db\Schema::getTableMetadata` cache refreshing (boboldehampsink)
- Bug #15875: afterSave for new models flushes unsaved data (shirase)
- Bug #16073: Fixed regression in Oracle `IN` condition builder for more than 1000 items (cebe)

64
framework/rbac/migrations/m180523_151638_rbac_updates_indexes_without_prefix.php

@ -0,0 +1,64 @@
<?php
/**
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
use yii\base\InvalidConfigException;
use yii\db\Migration;
use yii\rbac\DbManager;
/**
* Updates indexes without a prefix.
*
* @see https://github.com/yiisoft/yii2/pull/15548
*
* @author Sergey Gonimar <sergey.gonimar@gmail.com>
* @since 2.0.16
*/
class m180523_151638_rbac_updates_indexes_without_prefix extends Migration
{
/**
* @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->dropIndex('auth_assignment_user_id_idx', $authManager->assignmentTable);
$this->createIndex('{{%idx-auth_assignment-user_id}}', $authManager->assignmentTable, 'user_id');
$this->dropIndex('idx-auth_item-type', $authManager->itemTable);
$this->createIndex('{{%idx-auth_item-type}}', $authManager->itemTable, 'type');
}
/**
* {@inheritdoc}
*/
public function down()
{
$authManager = $this->getAuthManager();
$this->dropIndex('{{%idx-auth_assignment-user_id}}', $authManager->assignmentTable);
$this->createIndex('auth_assignment_user_id_idx', $authManager->assignmentTable, 'user_id');
$this->dropIndex('{{%idx-auth_item-type}}', $authManager->assignmentTable);
$this->createIndex('idx-auth_item-type', $authManager->itemTable, 'type');
}
}
Loading…
Cancel
Save