Feature #12598 » statpress-primary-key.php
1 |
<?php
|
---|---|
2 |
|
3 |
global $wpdb; |
4 |
|
5 |
$tables = $wpdb->get_col( "SHOW TABLES LIKE '%statpress%'" ); |
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 |
}
|