private function parseIndexSql(Table $table, $keyName, $sql)
{
if ('PRIMARY' === $keyName) {
if (!preg_match_all('/`([^`]+)`/', $sql, $matches)) {
throw new \RuntimeException(sprintf('Primary key definition "%s" could not be parsed.', $sql));
}
$table->setPrimaryKey($matches[1]);
return;
}
if (!preg_match('/(.*) `([^`]+)` \\((.*)\\)/', $sql, $matches)) {
throw new \RuntimeException(sprintf('Key definition "%s" could not be parsed.', $sql));
}
$columns = [];
$flags = [];
foreach (explode(',', $matches[3]) as $column) {
preg_match('/`([^`]+)`(\\((\\d+)\\))?/', $column, $cm);
$column = $cm[1];
if (isset($cm[3])) {
$column .= '(' . $cm[3] . ')';
}
$columns[$cm[1]] = $column;
}
if (false !== strpos($matches[1], 'unique')) {
$table->addUniqueIndex($columns, $matches[2]);
} else {
if (false !== strpos($matches[1], 'fulltext')) {
$flags[] = 'fulltext';
}
$table->addIndex($columns, $matches[2], $flags);
}
}