<?php

global $wpdb;

$tables = $wpdb->get_col( "SHOW TABLES LIKE '%nf3_%'" );
foreach ( $tables as $table ) {
	if ( $wpdb->get_row( "SHOW INDEX FROM {$table} WHERE Key_name = 'PRIMARY'" ) ) {
		WP_CLI::log( "$table already has primary key" );
		continue;
	}
	$wpdb->query( "ALTER TABLE {$table} ADD PRIMARY KEY (`id`)" );
	WP_CLI::log( $table );
}
