When migrating a WordPress installation from one server to another, it is important that you verify the integrity of the database. The tables can be created properly but you must check for missing indexes and ensure that all primary key columns have the AUTO_INCREMENT column attribute.
Missing indexes and auto_increment column attributes in a WordPress database throw error messages which make it difficult to debug the problem and fix your WordPress installation.
When tables are missing indexes or the AUTO_INCREMENT column attributes are missing, data is saved to tables without a unique identifier which makes finding the data more difficult later when needed.
I got an email today from a person who paid to have their site migrated from one server to another. They told me about the horrendous process they had been through and yet they were still encountering problems.
When they tried to create a new page or post, they encountered this error – “You are currently editing the page that shows your latest posts.“
The person explained that they were not editing a page but creating a new page and the error message made absolutely no sense.
I did a search on Google and found numerous posts explaining that this error message was generated when an index was missing on the wp_posts table. This particular WordPress installation was a multi-site instance which complicated matters because the main site worked fine – new posts could be added without issue. It was the sub-site that was having the problem. So, I checked the wp_posts, wp_2_posts, and wp_3_posts tables in the database, I found that the indexes were in place. Thinking that the indexes could be corrupt, I deleted them and re-created them. The error still displayed.
Then I checked for the AUTO_INCREMENT attribute on the ID columns. Sure enough, they were missing on all the sub-site tables (wp_2_posts and wp_3_posts). I altered the tables to add it, retried the page and the error was gone.
The WordPress error messages generated don’t always make sense but if you encounter the error message “You are currently editing the page that shows your latest posts.” check your indexes and primary key column attribute for any missing AUTO_INCREMENT attributes.