From 166f8aa582f7308137e8789d71cd72304a011e5b Mon Sep 17 00:00:00 2001 From: Luciano Baraglia Date: Wed, 25 Dec 2013 20:25:29 -0300 Subject: [PATCH] Fix wrong array index in unique indexes for MySql --- framework/yii/db/mysql/Schema.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/yii/db/mysql/Schema.php b/framework/yii/db/mysql/Schema.php index 075389e..a649d8a 100644 --- a/framework/yii/db/mysql/Schema.php +++ b/framework/yii/db/mysql/Schema.php @@ -267,8 +267,8 @@ class Schema extends \yii\db\Schema $regexp = '/UNIQUE KEY\s+([^\(^\s]+)\s*\(([^\)]+)\)/mi'; if (preg_match_all($regexp, $sql, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { - $indexName = str_replace('`', '', $match[2]); - $indexColumns = array_map('trim', explode(',', str_replace('`', '', $match[3]))); + $indexName = str_replace('`', '', $match[1]); + $indexColumns = array_map('trim', explode(',', str_replace('`', '', $match[2]))); $uniqueIndexes[$indexName] = $indexColumns; } }