• Resolved Oxford Metadata Ltd

    (@oxfordmetadata)


    During update to the latest version in the first two (out of two) sites we are getting the following error:

    2025/06/09 21:37:51 [error] 2529806#2529806: *9268286 FastCGI sent in stderr: “PHP message: WordPress database error Multiple primary key defined for query ALTER TABLE wp_woocommerce_order_itemmeta ADD PRIMARY KEY  (meta_id) made by require_once(‘wp-admin/admin.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::install_core, WC_Install::create_tables, dbDelta; PHP message: WordPress database error Duplicate key name ‘meta_key’ for query ALTER TABLE wp_woocommerce_order_itemmeta ADD KEY meta_key (meta_key(32)) made by require_once(‘wp-admin/admin.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::install_core, WC_Install::create_tables, dbDelta; PHP message: WordPress database error Duplicate key name ‘order_key’ for query ALTER TABLE wp_wc_order_operational_data ADD KEY order_key (order_key) made by require_once(‘wp-admin/admin.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::install_core, WC_Install::create_tables, dbDelta; PHP message: WordPress database error Duplicate key name ‘meta_key_value’ for query ALTER TABLE wp_wc_orders_meta ADD KEY meta_key_value (meta_key(100),meta_value(82)) made by require_once(‘wp-admin/admin.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::install_core, WC_Install::create_tables, dbDelta” while reading response header from upstream, client: 2a02:587:3223:6100:a814:cf65:4262:9485, ser

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi @oxfordmetadata,

    I understand you’re seeing a series of database errors during the update to WooCommerce 9.9.3, particularly around duplicate or conflicting keys during the dbDelta execution. That’s definitely concerning when you’re just trying to run a smooth update.

    The errors you shared suggest that the update script is trying to add primary or secondary keys to tables where those already exist, which usually means the database schema has diverged slightly from what WooCommerce expects. This can happen with older installs, manual database edits, or previously interrupted updates.

    To move forward safely, here’s what I’d recommend:

    1. Backup your database if you haven’t already.
    2. Check for duplicate indexes manually in your database for tables like:
      • wp_woocommerce_order_itemmeta
      • wp_wc_order_operational_data
      • wp_wc_orders_meta
      You can use a tool like phpMyAdmin or a DB client to look at existing indexes. If meta_key, order_key, or meta_key_value indexes already exist, WooCommerce is trying to add them again — which causes the error.
    3. Do not manually delete these indexes unless you’re certain they’re not being used. Instead, we recommend using the built-in WooCommerce database tools:
      • Go to WooCommerce > Status > Tools
      • Run “Update WooCommerce Database”
      • You can also try the “Verify database schema” tool if available
    4. If the issue persists, you can temporarily enable debugging in wp-config.php to capture any additional detail during the update:
    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_LOG', true );
    define( 'WP_DEBUG_DISPLAY', false );

    Once done, check the log in /wp-content/debug.log.

    If you’re still seeing errors or unsure about the index state, feel free to share the result of SHOW INDEX FROM wp_woocommerce_order_itemmeta; and similar queries, and I can help interpret it.

    Let me know how it goes!

    Thread Starter Oxford Metadata Ltd

    (@oxfordmetadata)

    Thank you. The issue had to do with the keys added by Index MySQL plugin that we used for performance. It is great to see that some of the indexes added by this brilliant plugin are now part of the core!

    Thank you.

    Hi @oxfordmetadata,

    Thank you for the update. I’m really glad you were able to trace the issue back to the indexes created by the Index MySQL plugin. That makes perfect sense, and it’s great to hear that you’re excited about the performance-focused improvements now being incorporated directly into WooCommerce core.

    If everything is running smoothly now and the update completed without further issues, then you’re all set. If you run into anything else during your next update or with database optimization, feel free to reach out anytime.

    If WooCommerce has been useful for your store and you appreciate the support you’ve received, we’d truly appreciate it if you could leave us a quick review here: https://ww.wp.xz.cn/support/plugin/woocommerce/reviews/#new-post

    Wishing you smooth updates ahead!

    joy0114

    (@joy0114)

    Hi @oxfordmetadata,

    Do you mean to say that it is not necessary (or even that it should NOT be done) to “convert” the tables wc_orders_meta
    woocommerce_order_itemmeta ?

    Indeed, after Woocommerce was updated to 9.9.3, Index Mysql offers to convert them, but at the same time, also shows that these tables have an index…

    Thanks in advance for any advice !
    Best regards

    Thread Starter Oxford Metadata Ltd

    (@oxfordmetadata)

    Νο @joy0114 ! They are needed indeed. But if you already have them optimized with index mysql plugin you will get this error during the upgrade to 9.9.

    What I did was to revert my keys to normal in index mysql, then upgraded woocommerce, and then re-applied them, just to ensure max compatibility with woo (you never know… )

    joy0114

    (@joy0114)

    Ok, I understand.

    Thanks a lot for sharing this tip !
    have a good day.

    Best regards

    Hi @oxfordmetadata and @joy0114,

    Thank you both for continuing the discussion and sharing your insights — it’s always great to see community members helping each other out! This kind of collaboration makes a real difference, especially with more technical upgrade-related issues like this one.

    If you run into any other issue or need further help down the road, feel free to open a new topic here in the forum. We’re always happy to help where we can.

    And if WooCommerce has been useful for your store and you appreciate the support and community you’ve found here, we’d truly appreciate it if you could leave us a quick review: https://ww.wp.xz.cn/support/plugin/woocommerce/reviews/#new-post

    Wishing you both a smooth and optimized WooCommerce experience ahead!

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

The topic ‘Database error warning during update to 9.9.3’ is closed to new replies.