Skip to content

Instantly share code, notes, and snippets.

@aschweigert
Last active December 29, 2015 14:29
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aschweigert/f5dd03e04bea91797c0c to your computer and use it in GitHub Desktop.
Save aschweigert/f5dd03e04bea91797c0c to your computer and use it in GitHub Desktop.
Standalone WP -> Multisite migration queries
[prefix] is needed to push the new users/usermeta values outside of the range already populated in the database, usually for a site with an ID of 40 using 40,000 will work pretty well (unless some of your sites have a lot of users).
UPDATE wp_users
SET ID = ID + [prefix]
// Add two columns to the end of the wp_users table, spam and deleted. Both are TINYINT(2).
UPDATE wp_usermeta
SET user_id = user_id + [prefix]
UPDATE wp_usermeta
SET umeta_id = umeta_id + [prefix]
UPDATE wp_usermeta
SET meta_key = 'wp_ID_user_level'
WHERE meta_key = 'wp_user_level'
UPDATE wp_usermeta
SET meta_key = 'wp_ID_capabilities'
WHERE meta_key = 'wp_capabilities'
UPDATE wp_ID_posts
SET post_author = post_author + [prefix]
// usually you'll need to update links to uploaded files in the posts table, depends on your configuration and version of WP
UPDATE wp_ID_posts
SET post_content = replace(
post_content,
'wp-content/uploads/',
'wp-content/blogs.dir/ID/files/'
)
UPDATE wp_ID_comments
SET user_id = user_id + [prefix]
In wp_ID_settings check siteurl, home, upload_url_path
In wp_ID_settings change (key) wp_user_roles to wp_ID_user_roles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment