Include the index name so the manual sql fix validates. (#6365)

This commit is contained in:
Tony Murray
2017-04-05 10:20:14 -05:00
committed by GitHub
parent 2076e3655f
commit 0fd0b7cd6c

View File

@@ -2254,18 +2254,16 @@ function column_schema_to_sql($column_data)
function index_schema_to_sql($index_data)
{
if ($index_data['Name'] == 'PRIMARY') {
$index = 'PRIMARY KEY';
$index = 'PRIMARY KEY (%s)';
} elseif ($index_data['Unique']) {
$index = 'UNIQUE';
$index = "UNIQUE `{$index_data['Name']}` (%s)";
} else {
$index = 'INDEX';
$index = "INDEX `{$index_data['Name']}` (%s)";
}
$type = $index_data['Type'] != 'BTREE' ? " USING {$index_data['Type']}" : '';
$columns = implode(',', array_map(function ($col) {
return "`$col`";
}, $index_data['Columns']));
return "$index ($columns)$type";
return sprintf($index, $columns);
}