Project

General

Profile

tantan-flickr-table-keys.php

Add primary key column for tantan-flickr - Boone Gorges, 2020-04-08 11:12 AM

 
1
<?php
2

    
3
global $wpdb;
4

    
5
$cr_tables = $wpdb->get_col( "SHOW TABLES LIKE '%silas_flickr_cache%'" );
6
foreach ( $cr_tables as $cr_table ) {
7
        if ( $wpdb->get_var( "SHOW INDEX FROM {$cr_table} WHERE Key_name = 'PRIMARY'" ) ) {
8
                continue;
9
        }
10

    
11
        $query = "ALTER TABLE {$cr_table} ADD COLUMN flickrcache_id bigint(20) unsigned NOT NULL auto_increment PRIMARY KEY FIRST";
12

    
13
        $wpdb->query( $query );
14

    
15
        WP_CLI::log( $cr_table );
16
}