From 0fd0b7cd6cdeec0dd996e57e72648640f176931e Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Wed, 5 Apr 2017 10:20:14 -0500 Subject: [PATCH] Include the index name so the manual sql fix validates. (#6365) --- includes/functions.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/includes/functions.php b/includes/functions.php index 6c0525214b..5a7a66ab61 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -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); }