• Resolved Rob

    (@roballred)


    my rule is that when it takes 4x longer to find it than it does to ask, just ask. so sorry if this has been answered previously, I did not find it. When i create a subsite on my multisite install of wordpress. the site is assigned number (1,2,3) for a site id. when i delete a site, then add a new one, the value is keeps going to next value. I end up with site 2, 4, 7, 9 as I add and delete. I would like to reset that value, any suggestions.

    Thanks in advance
    Rob

Viewing 6 replies - 1 through 6 (of 6 total)
  • This is a native function of databases. IDs are not re-used.

    Logically, how would it work? If you were to create sites 1, 2 and 3; then delete site 2; if the database reset the index to 2, you’d end up with two items with an ID of 3.

    There are two ways to reset these IDs, but both are dangerous and tedious. The first is to wipe out your database every time you delete a site, then start over again. The second is to modify the auto-increment value for your blogs table in the database (but, again, what will the database do if you delete a site with an ID in the middle of your existing sites?).

    Thread Starter Rob

    (@roballred)

    I was really wanting to see if their was an easy button trick for resetting the primary key value, but really it sounds like a bad idea.

    thanks

    Also, the only person who sees that ID is you, the site admin. The users do not see it nor do they need to know it for any reason.

    I, too, would like to reset my IDs. I have two unused IDs that are currently right at the end. If I’m going to reset it, now’s the time, before I add another blog.

    Resetting the auto-increment in MySQL looks pretty straightforward…
    “ALTER TABLE some_table AUTO_INCREMENT=10000”

    But to which table would I apply this?

    Ps. I just applied the reset and it appears to have worked just fine. The table is wp_blogs.

    “ALTER TABLE wp_blogs AUTO_INCREMENT=10000”

    (With your desired blog ID in place of 10000, of course.)

    Yeah, I know that sometimes you just want the numbers to all line up.

    In my case, I’ve been playing with various multisite features and have added and deleted several test subsites. Thus, I had a nasty “gap” ??

    Since the subsites are all mine, and nobody is going to make another blog, I did that alter command using the autoincrement value as the current highest numbered site_id + 1. It worked with out a hitch.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘reset site id's on multisite’ is closed to new replies.