WordPress at Your Fingertips
function is not described

wc_update_343_cleanup_foreign_keys() WC 1.0

Remove duplicate foreign keys

No Hooks.

Return

null. Nothing.

Usage

wc_update_343_cleanup_foreign_keys();

Code of wc_update_343_cleanup_foreign_keys() WC 5.5.2

<?php
function wc_update_343_cleanup_foreign_keys() {
	global $wpdb;

	$results = $wpdb->get_results(
		"SELECT CONSTRAINT_NAME
		FROM information_schema.TABLE_CONSTRAINTS
		WHERE CONSTRAINT_SCHEMA = '{$wpdb->dbname}'
		AND CONSTRAINT_NAME LIKE '%wc_download_log_ib%'
		AND CONSTRAINT_TYPE = 'FOREIGN KEY'
		AND TABLE_NAME = '{$wpdb->prefix}wc_download_log'"
	);

	if ( $results ) {
		foreach ( $results as $fk ) {
			$wpdb->query( "ALTER TABLE {$wpdb->prefix}wc_download_log DROP FOREIGN KEY {$fk->CONSTRAINT_NAME}" ); // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
		}
	}
}