• Resolved therealgilles

    (@chamois_blanc)


    The update to WC 4.8.0 worked but produced the following database error in the WP debug.log file:

    WordPress database error Cannot add or update a child row: a foreign key constraint fails (<database_name>.#sql-alter-<numbers>, CONSTRAINT fk_wp_wc_download_log_permission_id FOREIGN KEY (permission_id) REFERENCES wp_woocommerce_downloadable_product_permissions (permissi) for query ALTER TABLEwp_wc_download_log`
    ADD CONSTRAINT fk_wp_wc_download_log_permission_id
    FOREIGN KEY (permission_id)
    REFERENCES wp_woocommerce_downloadable_product_permissions (permission_id) ON DELETE CASCADE; made by require(‘wp-blog-header.php’), require_once(‘wp-load.php’), require_once(‘wp-config.php’), require_once(‘wp-settings.php’), do_action(‘init’), WP_Hook->do_action, WP_Hook->apply_filters, WC_Install::check_version, WC_Install::install, WC_Install::create_tables

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @chamois_blanc,

    Thanks for providing the text of that error message!

    We most commonly see this issue when your wp_woocommerce_downloadable_product_permissions table is running with a different database engine than your wp_wc_download_log_permission_id table. For example, if one of the tables is running InnoDB and the other is running MyISAM, you’ll see this error because those aren’t compatible engines. This is the first thing I’d check.

    To check this, go to WooCommerce > Status and scroll down to the database section. Find each of those tables and look for the Engine value – you can see mine is InnoDB on my wp_woocommerce_downloadable_product_permissions table:


    Link to image: https://d.pr/i/gPMHcm

    If the engines are different between the two tables, get in touch with your hosting company. They should be able to help you switch the engine on one of those tables so that they’re compatible. They should also be able to advise you on which engine should be used based on the rest of your database and server setup.

    If you check the database engines and this isn’t the case – they are the same – please let us know and we’ll take another look!

    Thread Starter therealgilles

    (@chamois_blanc)

    Thank you for the reply. Interesting.

    Here is the first table:
    wp_woocommerce_downloadable_product_permissions Data: 0.02MB + Index: 0.17MB + Engine InnoDB

    I do not see a wp_wc_download_log_permission_id table (or anything else mentioning permissions). I’ve never used any downloadable products, so maybe that’s why the error happens?

    Hi @chamois_blanc,

    Thanks for checking that! That is definitely odd. I believe that table should exist even if you have no downloadable products on your site.

    Would you mind sharing your site’s system status here? Go to that same WooCommerce > Status page and click “Get System Report” and then “Copy for Support.” Then paste your system status in your response here.

    Thank you!

    Hi @chamois_blanc,

    If the table is not present, as mentioned before it should still exist because it has to have a spot for potential downloadable products. In that case, you can disable and re-enable WooCommerce, as it should rebuild the database tables that might be missing.

    Another option is to go to WooCommerce > Status > Tools and select the tool for Verify Database Tables – this can verify the DB tables and make sure they are correct.

    If it comes back OK, please let us know and post the Status Report so we can take a further look.

    Thread Starter therealgilles

    (@chamois_blanc)

    ‘Verify Database Tables’ reported:
    Database verified successfully.

    I would not want to post the status report here. I will wait till it happens again and then open a ticket.

    Missy a11n

    (@m155y5)

    Automattic Happiness Engineer

    Hi @chamois_blanc

    I would not want to post the status report here. I will wait till it happens again and then open a ticket.

    Sounds great. I’m going to go ahead and mark this thread as resolved. If you have any other questions please feel free to start a new thread.

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

The topic ‘Database error during WC 4.8.0 update’ is closed to new replies.