Lost your WordPress table indexes, keys and auto_increment fields ? How to re add your primary keys? Lost all that when moving databases?
You could use some searching on the web and and up with a whole lot of manual work copying from pages with outdated database queries. Including guessing/estimating of your next autoincrement value..
We wrote a script that parses the build-in schedule.php from the most current version of WordPress ( @see wp-admin/includes/schema.php ) . We translate it in realtime all to some queries that are up to date. So the output will be up to date for all WordPress versions. It is not a fixed script output for a specific version, it will show the latest version of WP Core.
And .. we even have fixes for you to delete rows where your primary key is lost and the “primary key” values are zero (0). The script will remove those corrupted rows.
The script will give you DELETE and MODIFY/ALTER table queries. It will also enable auto increments.
Warning: this is tested on mysql and mariadb for a single WP Core site (not a multisite), it might not work on your site, so make a backup first.Read me first
This will only fix your WordPress Core tables (users, posts etc..) it will not fix any other non-WP-Core tables (such as GravityForms or any other plugin or custom tables).
Call the free fixer script here. You only have to rename the database prefix to wp_ or whatever your table prefix is (see your wp-config.php for that).
Or buy the fixer script here to run it on your WordPress server, that will automatically set your database prefix to YOUR own prefix and it will do an extra check and show you all the tables without any keys.
This script will fix the following database symptoms and errors based on a missing primary key:
- PHP errors in your error log: “WordPress database error: [Duplicate entry ‘0’ for key ‘PRIMARY’]”
- You trying to re-add the primary key with increment resulting in “#1075 – Incorrect table definition; there can be only one auto column and it must be defined as a key”
- Not able to create new pages, all pages have the Publish button replaced with Submit for review. (See Dutch screenshot “Inzenden voor beoordeling”)
No permalink, just “?preview=true”