Solved! “Uncaught RuntimeException: Error saving action: Error saving action: Database error.” … “ActionScheduler_DBStoreMigrator.php”

I have been having issues with a Woocommerce installation, where I received an error like this:

Fatal error: Uncaught RuntimeException: Error saving action: Error saving action: Database error. in
scheduler/classes/migration/ActionScheduler_DBStoreMigrator.php:44 Stack trace: #0 /home/clickna8/public_html/
ActionScheduler_DBStoreMigrator->save_action(Object(ActionScheduler_Action), NULL) #1 /home/clickna8/public_html/
content/plugins/woocommerce/packages/action-scheduler/classes/ActionScheduler_ActionFactory.php(177): ActionScheduler_HybridStore-
>save_action(Object(ActionScheduler_Action)) #2 /home/clickna8/public_html/
scheduler/classes/ActionScheduler_ActionFactory.php(84): ActionScheduler_ActionFactory->store(Object(ActionScheduler_Action)) #3
/home/clickna8/public_html/ in /home/clickna8/public_html/
content/plugins/woocommerce/packages/action-scheduler/classes/migration/ActionScheduler_DBStoreMigrator.php on line 44

The issue also presented itself in the form of a massive wp_actionscheduler_logs table. Like, 1000s of entries every few seconds, crashing my hosting setup and ruining many a day of my life.

Searching the web on this one was unhelpful, but I figured it out myself. The problem was that the site was built with a staging environment, and when it was transferred back the database got kerfuffled. Straight up corrupted.

So, via phpMyAdmin, I had to go in and correct everything manually. Here’s how to do that.

The Database Tables in Question

screenshot of action scheduler tables added by Woocommerce
The tables we’re working with are these “actionscheduler” ones.

There are four tables we want to check. They all start with (typically) wp_ but may be a bit different depending on who and how your WordPress installation as setup. But they all have _actionscheduler_ in the name.


Deleting the Existing Data

So, firstly, the issue is very likely that the data in the tables is corrupt, specifically in that the primary key column has a bunch of 0s. If you click on the Browse link next to one of them, say wp_actionscheduler_actions, and there’s a column with a bunch of 0s in it, that’s no good.

screenshot of column described
This one is correct. If those 1, 2, 3, 4, 5, and 6 were all zeros, that would be no good.

To empty the data from a column:

  1. Backup your database. You’re already in phpMyAdmin so there’s really no excuse not to do so.
  2. Deactivate Woocommerce. You don’t want it to try and create new ones while you’re trying to empty out the old ones.
  3. Click Empty next to the table in phpMyAdmin, the last button shown in this screenshot:
    showing the empty link in phpmyadmin

This is important. Without this, and as long as there are all zeros in those columns, we cannot proceed!

Correct Indexes, Auto-increments and Primary Keys

Once all four tables have been emptied, we need to get them setup correctly. For each of them, we’ll need to click on Structure next to their entry:

screenshot showing here to click
Click on Structure next to the table you want to work with.

Each table’s structure has to be setup correctly in order for Woocommerce to add new entries. Here is the correct structure for the wp_actionscheduler_actions table:

screenshot of the proper structure for this table
This is what everything should look like in this _actions table.

Chances are, yours won’t have those gold and silver keys next to the table names, nor will one of them read in the Extras column.

If you didn’t have the columns of zeros in any of the tables, and your gold / silver keys and AUTO_INCREMENT are all set, then what we’re addressing in this post is likely not the issue for you.

So how do we get all of those icons?

To get a grey key next to a table, we need to set it to “index”. To do that, you click this link to the right of it:

link to make a table "Indexed"

Do that with all of the columns that require it, based on the screenshots of which tables need which structures below.

To get the gold key, aka setting that column as “primary” you click the gold key icon / link next to it:

link to set a table as primary

Finally, to make sure we have the “Extras” column set to AUTO_INCREMENT, we need to click this Change link next to the column with the gold key / primary:

Change link

You’ll see an interface like this:

phpMyAdmin change structure interface

Check this A_I box:

checkbox to toggle auto increment

Click Save and you should be good to go. If a pink box comes up stating something about how you can’t change it because of duplicate keys, you need to empty that table again as outlined above, and you probably didn’t disable Woocommerce.

Do this for each of the four tables.

Proper Settings for Each Action Scheduler Table


screenshot of wp_actionscheduler_actions structure
Screenshot of wp_actionscheduler_actions structure.


screenshot of wp_actionscheduler_claims structure
Screenshot of wp_actionscheduler_claims structure.


screenshot of wp_actionscheduler_groups structure
Screenshot of wp_actionscheduler_groups structure.


screenshot of wp_actionscheduler_logs structure
Screenshot of wp_actionscheduler_logs structure.

Up Next: Prevent WordPress from Showing an Email Address as a Commenter's Name