<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Matt [Danger] &#187; multi-site</title>
	<atom:link href="http://mattdanger.net/tag/multi-site/feed/" rel="self" type="application/rss+xml" />
	<link>http://mattdanger.net</link>
	<description>One step closer to world domination</description>
	<lastBuildDate>Fri, 02 Dec 2011 18:20:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Making database changes to Drupal multi-sites</title>
		<link>http://mattdanger.net/2009/12/making-database-changes-to-drupal-multi-sites/</link>
		<comments>http://mattdanger.net/2009/12/making-database-changes-to-drupal-multi-sites/#comments</comments>
		<pubDate>Tue, 22 Dec 2009 03:29:22 +0000</pubDate>
		<dc:creator>Matt Danger</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Drupal]]></category>
		<category><![CDATA[multi-site]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://mattdanger.net/?p=258</guid>
		<description><![CDATA[The company I work for hosts over 150 Drupal sites in a multi-site configuration and every so often I need to publish a change to the code that requires a database change. The large number of sites we host means that performing manual changes would require too much time and carries a chance of error.&#8230;]]></description>
			<content:encoded><![CDATA[<p>The company I work for hosts over 150 Drupal sites in a multi-site configuration and every so often I need to publish a change to the code that requires a database change. The large number of sites we host means that performing manual changes would require too much time and carries a chance of error. I&#8217;ve come up with a simple solution.</p>
<p>I first create a PHP script that bootstraps Drupal. Here is an example of a script that will rebuild the menu router tables.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Bootstrap</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'includes/bootstrap.inc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'includes/common.inc'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
drupal_bootstrap<span style="color: #009900;">&#40;</span>DRUPAL_BOOTSTRAP_FULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Rebuild menus</span>
menu_rebuild<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">print</span> <span style="color: #0000ff;">'Menu rebuild complete\n'</span><span style="color: #339933;">;</span></pre></div></div>

<p>I name this script <code>rebuild_menus.php</code> and upload it to my Drupal directory. Then, I create a text file on my desktop that contains a list of all the Drupal websites. This is an abbreviated example:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//example1.com</span>
http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//example2.com</span>
http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//example3.com</span>
http<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//example4.com</span></pre></div></div>

<p>Finally, I execute the script on all the sites by running the following command:</p>
<p><code>for url in `cat list.txt`; do echo "Running script on $url"; curl $url/rebuild_menus.php; echo; done</code></p>
]]></content:encoded>
			<wfw:commentRss>http://mattdanger.net/2009/12/making-database-changes-to-drupal-multi-sites/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

