Hello there,
I hope you’re doing well :D.
We created the following code in order to regenerate the tables and execute the migration process again.
Please, try to add the following code in the functions.php of your active theme
if ( ! function_exists( 'yith_wapo_check_db_400' ) ) {
function yith_wapo_check_db_400() {
// Add ?yith_addons=1 to the URL inside the admin panel will execute all the code.
if ( isset( $_GET['yith_addons'] ) ) {
global $wpdb;
require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
$blocks_table = $wpdb->prefix . 'yith_wapo_blocks';
$assoc_table = $wpdb->prefix . 'yith_wapo_blocks_assoc';
$charset_collate = $wpdb->get_charset_collate();
// 1. BLOCKS TABLE - START
$sql_blocks = "CREATE TABLE {$wpdb->prefix}yith_wapo_blocks (
id INT(3) NOT NULL AUTO_INCREMENT,
user_id BIGINT(20),
vendor_id BIGINT(20),
settings LONGTEXT,
priority DECIMAL(9,5),
visibility INT(1),
creation_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
last_update TIMESTAMP,
name varchar(255) NOT NULL,
product_association varchar(255),
exclude_products tinyint(1) NOT NULL,
user_association varchar(255),
exclude_users tinyint(1) NOT NULL,
PRIMARY KEY (id)
) $charset_collate;";
if ( function_exists( 'maybe_create_table' ) ) {
maybe_create_table( $blocks_table, $sql_blocks );
}
// CREATE COLUMNS FOR BLOCKS TABLE.
$blocks_columns = array(
'name' => 'ALTER TABLE ' . $blocks_table . ' ADD name varchar(255) NOT NULL;',
'product_association' => 'ALTER TABLE ' . $blocks_table . ' ADD product_association varchar(255);',
'exclude_products' => 'ALTER TABLE ' . $blocks_table . ' ADD exclude_products tinyint(1) NOT NULL;',
'user_association' => 'ALTER TABLE ' . $blocks_table . ' ADD user_association varchar(255);',
'exclude_users' => 'ALTER TABLE ' . $blocks_table . ' ADD exclude_users tinyint(1) NOT NULL;',
);
foreach ( $blocks_columns as $block_column => $block_statement ){
if ( function_exists( 'maybe_add_column' ) ) {
maybe_add_column($blocks_table, $block_column, $block_statement);
}
}
// BLOCKS TABLE - END
// 2. BLOCKS ASSOC TABLE - START
$sql_associations = "CREATE TABLE {$wpdb->prefix}yith_wapo_blocks_assoc (
rule_id bigint(20) NOT NULL,
object varchar(255) NOT NULL,
type varchar(50) NOT NULL,
KEY
type
(type
),
KEY object
(object
)
) $charset_collate;";
if ( function_exists( 'maybe_create_table' ) ) {
maybe_create_table($assoc_table, $sql_associations);
}
// CREATE COLUMNS FOR ASSOCIATION TABLE.
$assoc_columns = array(
'rule_id' => 'ALTER TABLE ' . $assoc_table . ' ADD rule_id varchar(255) NOT NULL;',
'object' => 'ALTER TABLE ' . $assoc_table . ' ADD object varchar(255) NOT NULL;',
'type' => 'ALTER TABLE ' . $assoc_table . ' ADD type varchar(50) NOT NULL;',
);
foreach ( $assoc_columns as $assoc_column => $assoc_statement ){
if ( function_exists( 'maybe_add_column' ) ) {
maybe_add_column($assoc_table, $assoc_column, $assoc_statement);
}
}
// BLOCKS ASSOC TABLE - END
// 3. UPDATE OPTION - START
update_option( 'yith_wapo_db_update_scheduled_for', '2.0.0' );
update_option( 'yith_wapo_db_version_option', '2.0.0' );
//UPDATE OPTION - END
}
}
add_action( 'admin_init', 'yith_wapo_check_db_400' );
}
Then try to visit your site adding the following url
https://yoursite.com/wp-admin/admin.php?page=yith_wapo_panel&yith_addon=1
Note: you need to change yoursite.com and add your domain.
Note2: I suggest you to execute the code on a staging site before to set it on production. In this way you’ll prevent to generate problems on your production site.
Please, try it and let me know.
Have a good day