• Resolved sc0ttius

    (@sc0ttius)


    We had an old version of mailchimp for WP installed and recent attempted to upgrade to the latest version. The existing table in the database seems to refer to the ‘data’ column as ‘merged_vars’.

    When I attempt to sign up, I receive the error:

    WordPress database error Unknown column 'data' in 'field list' for query 
    
    INSERT INTO <code>wp_mc4wp_log</code> (<code>email</code>, <code>list_ids</code>, <code>data</code>, <code>type</code>, <code>related_object_ID</code>, <code>url</code>, <code>datetime</code>) VALUES ('xxxxx@gmail.com', '294axxxxx', '[]', 'mc4wp-top-bar', '0', 'https://xxxxx/xxx-xxx/', '2016-02-08 14:13:29') 
    
    made by require('wp-blog-header.php'), wp, WP->main, do_action_ref_array, call_user_func_array, MailChimp\\TopBar\\Bar->init, MailChimp\\TopBar\\Bar->listen, MailChimp\\TopBar\\Bar->process, do_action('mctb_subscribed'), call_user_func_array, MC4WP_Logger->log_top_bar_request, MC4WP_Logger->add, referer: https://xxx.xxxx.xxx/xxxxx/

    I tried disabling and reenabling the plugin, but nothing seems to be working. Why is it expecting a column named ‘data’ but my existing column is ‘merged_vars’?

    https://wordpress.org/plugins/mailchimp-for-wp/

Viewing 1 replies (of 1 total)
  • Plugin Author Danny van Kooten

    (@dvankooten)

    Hi Scottius,

    I think we had contact over email but this seems to be the result of a database migration not running. I’m not sure why but running the following code (once) should fix the database column names.

    global $wpdb;
    
    $table_name = $wpdb->prefix . 'mc4wp_log';
    
    // merge columns form_ID and comment_ID into related_object_ID
    $wpdb->query( "ALTER TABLE {$table_name} CHANGE COLUMN form_ID related_object_ID BIGINT(20)" );
    $wpdb->query( "UPDATE {$table_name} SET related_object_ID = comment_ID WHERE related_object_ID = 0 AND comment_ID > 0 " );
    $wpdb->query( "ALTER TABLE {$table_name} DROP COLUMN comment_ID" );
    
    // add 'success' column
    $wpdb->query( "ALTER TABLE {$table_name} ADD COLUMN success TINYINT(1) DEFAULT 1" );
    
    // rename columns
    $wpdb->query( "ALTER TABLE {$table_name} CHANGE COLUMN signup_method method VARCHAR(255)" );
    $wpdb->query( "ALTER TABLE {$table_name} CHANGE COLUMN signup_type type VARCHAR(255)" );
    $wpdb->query( "ALTER TABLE {$table_name} CHANGE COLUMN merge_vars data TEXT" );
    
    // alter datatype of datetime
    $wpdb->query( "ALTER TABLE {$table_name} CHANGE COLUMN datetime datetime timestamp DEFAULT CURRENT_TIMESTAMP" );
    
    // change sign-up-form to just form
    $wpdb->query( "UPDATE {$table_name} SET type = 'form' WHERE type = 'sign-up-form'" );
    $wpdb->query( "UPDATE {$table_name} SET type = 'form' WHERE method = 'form'" );
    
    // drop method column
    $wpdb->query( "ALTER TABLE {$table_name} DROP COLUMN method" );

    If you need any help in running that code, please let me know. 🙂

Viewing 1 replies (of 1 total)

The topic ‘Database columns incorrect’ is closed to new replies.