When a WooCommerce order has no number: the AUTO_INCREMENT your migration left behind
A store migration usually ends with a quick smoke test: the homepage loads, the catalogue is there, an order from the test account goes through. Then, a day later, the owner calls to say that payments arrive at the gatew
A store migration usually ends with a quick smoke test: the homepage loads, the catalogue is there, an order from the test account goes through. Then, a day later, the owner calls to say that payments arrive at the gateway but no orders appear in the admin.
The symptom cluster
A broken database import rarely breaks one thing. The typical set is:
- the orders screen throws a critical error,
- the checkout refuses to accept a chosen pickup point or shipping address,
- new orders are not recorded at all, while the payment provider shows the transactions.
Three symptoms, one cause. That is worth knowing, because treating them separately wastes hours.
What actually breaks
Some export and import paths drop primary keys and the AUTO_INCREMENT counter. The tables exist, the rows are there, and the database still cannot assign an id to a new record. An order without an id is never written. An order that was never written has nothing for the shipping metadata to attach to, and nothing for the admin list to display.
How to confirm it in two queries
Check whether the keys survived the import:
SELECT table_name, auto_increment
FROM information_schema.tables
WHERE table_schema = DATABASE()
AND auto_increment IS NULL;
Tables that should have a counter and report NULL are your answer. For a single table, SHOW CREATE TABLE wp_posts; tells you immediately whether PRIMARY KEY and AUTO_INCREMENT are still declared.
In a WooCommerce store running High-Performance Order Storage, look at wp_wc_orders and wp_wc_order_addresses as well, because orders no longer live only in wp_posts.
Restore or repair
Rebuilding keys table by table is possible, and on a large catalogue it is a long evening with an uncertain result. Restoring the pre-migration database is faster and gives you a known state, but only if nothing of value has accumulated since the migration.
Three questions settle it, and they are for the owner rather than for you to assume. How many paid orders arrived since the failure? Do they know about the orders currently in progress? Did anyone change anything after the move? Three negatives mean restoring is cheaper.
The part that is not technical
This class of failure is silent. Nothing alerts you; the site stays up, the pages return 200, and uptime monitoring reports green while the store takes no money. What catches it is a check that someone actually performs: a look at the order count against the same weekday a week earlier.
If you run stores for clients, put that comparison into your routine. It costs a minute, and it is the difference between a client calling you and a client calling someone else.
I build and look after WooCommerce stores and WordPress sites for small businesses in Poland, including WordPress maintenance with backups, updates and monthly checks of exactly this kind.
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.