mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Include the index name so the manual sql fix validates. (#6365)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user