• Resolved klaus04

    (@klaus04)


    WordPress database error Unknown column 'post_id' in 'field list' for query
    INSERT INTO wp_offa_wc_users_voted(user_id, comment_id, vote_type,is_guest,post_id,date)VALUES('1',5650,1,0,35256,1616276093); made by do_action('wp_ajax_wpdVoteOnComment'), WP_Hook->do_action, WP_Hook->apply_filters, WpdiscuzHelperAjax->voteOnComment, WpdiscuzDBManager->addVoteType

    When you add new columns to a table, you should take care of the backward compatibly. This is new code:

    CREATE TABLE wp_offa_wc_users_voted2
    		(id INT(11) NOT NULL AUTO_INCREMENT,
    		user_id VARCHAR(32) NOT NULL,
    		comment_id INT(11) NOT NULL,
    		vote_type INT(11) DEFAULT NULL,
    		is_guest TINYINT(1) DEFAULT 0,
    		post_id BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
    		date INT(11) UNSIGNED NOT NULL DEFAULT 0,
    		PRIMARY KEY (id),
    		KEY user_id (user_id),
    		KEY comment_id (comment_id),
    		KEY vote_type (vote_type),
    		KEY is_guest (is_guest),
    		KEY post_id (post_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

    This is old code. Where are the new columns added?

    if (!$this->isTableExists($this->users_voted)) {
         $sql = "CREATE TABLE " . $this->users_voted . "(id INT(11) NOT NULL AUTO_INCREMENT,user_id VARCHAR(255) NOT NULL, comment_id INT(11) NOT NULL, vote_type INT(11) DEFAULT NULL, is_guest TINYINT(1) DEFAULT 0, PRIMARY KEY (id), KEY user_id (user_id), KEY comment_id (comment_id),  KEY vote_type (vote_type), KEY is_guest (is_guest)) ENGINE=MyISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci AUTO_INCREMENT=1;";
         dbDelta($sql);
    }

    I had to go through so much trouble to debug and fix this issue. And you don’t even delete your table after plugin deletion. Have you added any more new columns that I need to worry about? Or that was it?

    Also your plugin loads “huge” JS and CSS files, 85-90% of which is never used (Tested in Chrome’s show coverage after testing all functionality). Good that you have added many new features to your plugin, but you should load JS and CSS having code for only the user-configured features.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support gVectors Support

    (@gvectorssupport)

    @klaus04,

    Please navigate to Dashboard > wpDiscuz > Tools admin page and click on the “Fix Tables” button in the “Database Operations” section. It should solve the issue.

    Thread Starter klaus04

    (@klaus04)

    That doesn’t work. Already tried that before wasting my whole day to debug the issue and adding the missing columns manually.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Columns missing – wp_offa_wc_users_voted’ is closed to new replies.