Do not try and create primary key using upgrade routine, dbdelta does that automatically. Just drop the key if it exists and add a new unique key.

This commit is contained in:
Gerhard 2018-10-15 14:07:48 +02:00
parent 74693979db
commit d3e59b770b
1 changed files with 14 additions and 3 deletions

View File

@ -1999,9 +1999,20 @@ function wc_update_350_reviews_comment_type() {
function wc_update_350_change_woocommerce_sessions_schema() {
global $wpdb;
$results = $wpdb->get_results( "
SELECT CONSTRAINT_NAME
FROM information_schema.TABLE_CONSTRAINTS
WHERE CONSTRAINT_SCHEMA = '{$wpdb->dbname}'
AND CONSTRAINT_TYPE = 'UNIQUE'
AND CONSTRAINT_NAME = 'session_id'
AND TABLE_NAME = '{$wpdb->prefix}woocommerce_sessions'
" );
if ( $results ) {
$wpdb->query(
"ALTER TABLE `{$wpdb->prefix}woocommerce_sessions` DROP PRIMARY KEY, DROP KEY `session_id`, ADD PRIMARY KEY(`session_id`), ADD UNIQUE KEY(`session_key`)"
"ALTER TABLE `{$wpdb->prefix}woocommerce_sessions` DROP KEY `session_id`, ADD UNIQUE KEY(`session_key`)"
);
}
}
/**