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:
parent
74693979db
commit
d3e59b770b
|
@ -1999,9 +1999,20 @@ function wc_update_350_reviews_comment_type() {
|
||||||
function wc_update_350_change_woocommerce_sessions_schema() {
|
function wc_update_350_change_woocommerce_sessions_schema() {
|
||||||
global $wpdb;
|
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(
|
$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`)"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue