Because I got annoyed about the fact that I cannot delete the “main site” I decided to see if I could shuffle everything around, assigning one of the later sites, to site 1, and shift site 1 to a higher number. IE, swap them, like 1 and 3.
So although this is not fully tested, and I make no promise that you will not completely erase everything, break it, blow it up, cause the LHC to form a blackhole, end life as we know it, it does seem to work. You must have a site with site_id=1 at the very least when you are all done shuffling around. I suggest moving ID 1 first, then switching your other site.
This will walk every table, looking for a site_id column, and update all the entries to reflect your change.
Again. BACKUP YOUR DATABASE COMPLETELY. If you break your site, you can just restore the database and try again. Though really I would do this on a dev box with an exact copy before I even think about doing it live. I still havent…
In case your wondering why I needed this, I want to separate out a site which is under MSM, but I want it to be a standalone on another server. Imagine a section of a site that got really popular, and needs it’s own sandbox for example. And obviously you need the correct license for it as well. So i copy the database to the new server, shuffle the sites on the new server, delete all the other MSM sites from that server, and I am left with the 1 site I wanted to move onto that new server.
Everything worked fine for me. The only problem I have found is that I have an orphaned category which is causing me problems when I try to delete the extra sites. But that may have been due to a prior hack I was implementing that I never fully cleaned up.
<?php
/*********************
Set these to your needs
**********************/
$orgID = 3; //this is the ID of the site you want to change to a new ID
$newID = 1; //this is the ID you want to set it to. Make sure you do not have this ID already in the database….
$prefix = 'exp_'; //your table prefix in your database
$server = "localhost";
$user = 'imauser';
$pass = 'reallyeasypassword';
$database = 'eedatabase';
/*********************
No Need to touch below this line
**********************/
$db = mysql_connect($server, $user, $pass,true) or die('Could not connect to database server.' );
mysql_select_db($database, $db) or die('Could not select database.');
$rs = mysql_query("SHOW TABLES");
while ($row = mysql_fetch_array($rs))
{
if ($row[0]==$prefix.'sites')
{
mysql_query("ALTER TABLE `{$row[0]}` CHANGE `site_id` `site_id` INT( 5 ) UNSIGNED NOT NULL",$db);
echo ' OFF';
}
mysql_query("update `{$row[0]}` set `site_id`=$newID where `site_id`=$orgID",$db);
echo ' updated';
if ($row[0]==$prefix.'sites')
{
mysql_query(" ALTER TABLE `{$row[0]}` CHANGE `site_id` `site_id` INT( 5 ) UNSIGNED NOT NULL AUTO_INCREMENT ",$db);
echo ' ON';
}
echo '
';
}
?>