Commit 5d3688ec by Qiang Xue

Merge pull request #1622 from lucianobaraglia/master

Fix wrong array index in unique indexes for MySql
parents 805e66cc 166f8aa5
...@@ -267,8 +267,8 @@ class Schema extends \yii\db\Schema ...@@ -267,8 +267,8 @@ class Schema extends \yii\db\Schema
$regexp = '/UNIQUE KEY\s+([^\(^\s]+)\s*\(([^\)]+)\)/mi'; $regexp = '/UNIQUE KEY\s+([^\(^\s]+)\s*\(([^\)]+)\)/mi';
if (preg_match_all($regexp, $sql, $matches, PREG_SET_ORDER)) { if (preg_match_all($regexp, $sql, $matches, PREG_SET_ORDER)) {
foreach ($matches as $match) { foreach ($matches as $match) {
$indexName = str_replace('`', '', $match[2]); $indexName = str_replace('`', '', $match[1]);
$indexColumns = array_map('trim', explode(',', str_replace('`', '', $match[3]))); $indexColumns = array_map('trim', explode(',', str_replace('`', '', $match[2])));
$uniqueIndexes[$indexName] = $indexColumns; $uniqueIndexes[$indexName] = $indexColumns;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment