| @@ -34,10 +34,16 @@ | ||
| 34 | 34 | `meta` LONGTEXT NULL, |
| 35 | 35 | `created_at` TIMESTAMP NULL, |
| 36 | 36 | `updated_at` TIMESTAMP NULL, |
| 37 | 37 | INDEX `{$indexPrefix}_user_id` (`user_id`), |
| 38 | - INDEX `{$indexPrefix}_username` (`username`) | |
| 38 | + INDEX `{$indexPrefix}_username` (`username`), | |
| 39 | + INDEX `{$indexPrefix}_last_activity` (`last_activity`) | |
| 39 | 40 | ) $charsetCollate;"; |
| 40 | 41 | dbDelta($sql); |
| 42 | + } | |
| 43 | + | |
| 44 | + $indexNames = $wpdb->get_col("SHOW INDEX FROM $table", 2); | |
| 45 | + if (!in_array("{$indexPrefix}_last_activity", $indexNames, true)) { | |
| 46 | + $wpdb->query("ALTER TABLE $table ADD INDEX `{$indexPrefix}_last_activity` (`last_activity`)"); | |
| 41 | 47 | } |
| 42 | 48 | } |
| 43 | 49 | } |