Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Database update schema integrity question

Discussion in 'Misc WordPress Requests' started by Mike, Oct 25, 2017.

  1. Mike


    Database update schema integrity question, by Mike

    Wordpress does not seem to check if database structure/scheme on existing sites is equal to how it would be on a new install.


    • How can I check the validity & integrity of the WordPress core database structure/scheme to detect differences in how the tables are setup (think constraints etc.) and how it should be by default in the most recent version of WordPress?

    Description of problem
    When trying to add a category I receive the error:

    WordPress database error: [Duplicate entry ‘test’ for key ‘slug’] INSERT INTO wp_terms (name, slug, term_group) VALUES (‘Test’, ‘test’, 0)

    What seems to be the cause of the problem?
    My install does not allow a category (test) with the same slug as an existing tag (test). WordPress should allow this.

    On further investigation: in wp_terms table, the field slug has a UNIQUE constraint. This was changed in WordPress 4.1 three years ago.(Link to trac 22023

    Duplicates are now prevented in WordPress code instead of in the database, but it seems like my site has skipped one or more database updates.

    In short
    My install is up to date. But my database structure/scheme is not up to date. wp_repair, wp_optimize etc. do not flag this.

    I was able to fix this but potentially my database still has other undetected differences.

    Temporary fix
    I manually removed the index/UNIQUE constraint on the slug field in wp_terms in the database. I tested and validated that duplicate slugs can now be created, while still unique in each taxonomy. (tags/categories)

    I would love to hear your thoughts on this! Depending on feedback I might submit this as a bug.

    Database update schema integrity question

Share This Page

Monarch Social Sharing Plugin