Project

General

Profile

Feature #12598 » woo-custom-nav-primary-key.php

Add primary keys to woo custom nav tables - Boone Gorges, 2020-04-08 11:52 AM

 
1
<?php
2

    
3
global $wpdb;
4

    
5
$tables = $wpdb->get_col( "SHOW TABLES LIKE '%woo_custom_nav%'" );
6
foreach ( $tables as $table ) {
7
	if ( $wpdb->get_row( "SHOW INDEX FROM {$table} WHERE Key_name = 'PRIMARY'" ) ) {
8
		continue;
9
	}
10
	$wpdb->query( "ALTER TABLE {$table} ADD PRIMARY KEY (id)" );
11
	WP_CLI::log( $table );
12
}
(6-6/9)