<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/stylesheets/rss.css" type="text/css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Yup Dot Com: Bruce Tate on Rails Migrations</title>
    <link>http://www.yup.com/articles/2006/08/17/bruce-tate-on-rails-migrations</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Advanced Web Services</description>
    <item>
      <title>Bruce Tate on Rails Migrations</title>
      <description>&lt;p&gt;&lt;img style="float: right; border: 1px dotted #ccc; margin: 4px; padding: 4px;" src="http://static.flickr.com/27/67673887_5480282dc5_m.jpg" /&gt;&lt;/p&gt;

&lt;p&gt;Bruce Tate, a Java book author and Ruby on Rails advocate, discusses the advantages of Ruby on Rails database migration strategy, and concludes:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The migrations story in Java programming is not nearly as robust. Some products have spot solutions for some of the schema migrations problems, but without a systemic process for coordinating schema changes &amp;#8211; both up and down &amp;#8211; dealing with changes in the data and object model can be a difficult task. The Rails solution has some core advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rails migrations are DRY (don&amp;#8217;t repeat yourself). With Rails, you specify each column definition exactly once: in the migration. Some other mappers force you to specify a column six times: in the schema, the getter, the setter, the model&amp;#8217;s instance variable, the &amp;#8220;from&amp;#8221; mapping, and the &amp;#8220;to&amp;#8221; mapping.&lt;/li&gt;
&lt;li&gt;Rails migrations allow data migration as well as schema migration.&lt;/li&gt;
&lt;li&gt;Rails migrations let you use model logic with your data migration where SQL scripts don&amp;#8217;t.&lt;/li&gt;
&lt;li&gt;Rails migrations are database independent, but SQL scripts aren&amp;#8217;t.&lt;/li&gt;
&lt;li&gt;Rails migrations allow direct SQL for unsupported extensions (such as stored procedures or constraints), while some ORM mappers don&amp;#8217;t.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With all of the benefits of migrations, you&amp;#8217;d expect a complex piece of code, but they are incredibly simple. Migrations have meaningful names and version numbers. Each migration, has an up and down method. Finally, a rake task coordinates running them in the correct order. This simple strategy is also revolutionary. The idea of expressing each schema change not in the model but as a distinct migration is both elegant and effective. Coordinating both data and schema changes is another paradigm shift, and an effective one. Best of all, these ideas are completely language agnostic. If you&amp;#8217;re building a new Java wrapping framework, you&amp;#8217;d do well to consider migrations.&lt;/p&gt;

&lt;/blockquote&gt;

&lt;p&gt;I personally take full advantage of migrations during development and maintenance of Ruby on Rails, and they have forever solved the chicken-and-egg data, code, and schema synchronization problem which made moving from development to production a unweildy and error-prone process in the past. It&amp;#8217;s also important to have a histor of the schema changes over time so that if a problem arises, you can track back to the exact change and schema migration which caused it.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www-128.ibm.com/developerworks/web/library/j-cb08156.html?ca=dgr-lnxw03RailsMigration"&gt;Crossing Borders: Rails Migrations Article&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://wiki.rubyonrails.org/rails/pages/UnderstandingMigrations"&gt;Understanding Migrations @ Rails Wiki&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Thu, 17 Aug 2006 10:41:00 -0400</pubDate>
      <guid isPermaLink="false">urn:uuid:19f6d2a7-90fb-455e-834c-95ec3b34ac6a</guid>
      <author>Daniel Butler</author>
      <link>http://www.yup.com/articles/2006/08/17/bruce-tate-on-rails-migrations</link>
      <category>Ruby on Rails</category>
    </item>
  </channel>
</rss>
