<?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>Codedrop™ Weblog &#187; Migrations</title>
	<atom:link href="http://www.codedrop.ca/blog/archives/tag/migrations/feed" rel="self" type="application/rss+xml" />
	<link>http://www.codedrop.ca/blog</link>
	<description>Drop'n some code and other tech tidbits...</description>
	<lastBuildDate>Sun, 01 Jan 2012 07:48:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Automate your non-rails db migrations with Capistrano and AutoPatch</title>
		<link>http://www.codedrop.ca/blog/archives/191</link>
		<comments>http://www.codedrop.ca/blog/archives/191#comments</comments>
		<pubDate>Tue, 10 Nov 2009 20:53:38 +0000</pubDate>
		<dc:creator>groll</dc:creator>
				<category><![CDATA[Build Automation]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[Migrations]]></category>

		<guid isPermaLink="false">http://www.codedrop.ca/blog/?p=191</guid>
		<description><![CDATA[After working in a rails environment for the past year I found it terribly difficult to go back to traditional database deployment / upgrade practices. Migrations are a beautiful way to properly version, co-ordinate and apply the changes you need to your various database environments.  I never knew of a way to do this in [...]]]></description>
			<content:encoded><![CDATA[<p>After working in a rails environment for the past year I found it terribly difficult to go back to traditional database deployment / upgrade practices.</p>
<p>Migrations are a beautiful way to properly version, co-ordinate and apply the changes you need to your various database environments.  I never knew of a way to do this in a non-rails environment, until now. Step in <a href="http://autopatch.sourceforge.net/index.php">AutoPatch</a>.</p>
<p>Some alternatives to AutoPatch exist such as <a href="http://migrate4j.sourceforge.net/">migrate4j</a> and <a href="http://www.liquibase.org/">Liquibase</a>. Each with their own flavor of how to tackle the problem.  AutoPatch was the winner for me as you don&#8217;t have to write your migrations in some custom DSL (xml in the case of Liquibase, or java for migrate4j).  Our existing .sql scripts worked just fine!</p>
<p>Our shop is currently using <a href="http://www.capify.org/index.php/Capistrano">Capistrano</a> for deployments.  Blending Autopatch with Capistrano was relatively straightforward.  Below are two sample tasks that can be added to facilitate AutoPatch&#8217;s cmd line info and migrate calls.</p>
<p><code> desc "Display database migration levels."<br />
task :dbinfo do<br />
cmdAPClasspath = "#{deployDir}/applications/database/lib/oracle/ojdbc14_g.jar" \<br />
+ ":#{deployDir}/dist/prepare/database" \<br />
+ ":#{deployDir}/lib/java/tk-autopatch-1.2-b-cvs.jar" \<br />
+ ":#{deployDir}/lib/java/log4j-1.2.8.jar" \<br />
+ ":#{deployDir}/lib/java/commons-logging-1.0.3.jar" \<br />
+ ":#{deployDir}/lib/java/commons-collections-3.2.1.jar" \<br />
+ ":#{deployDir}/lib/java/commons-lang-2.2.jar" \<br />
+ ":#{deployDir}/lib/java/tk-util-1.1.2.jar"<br />
cmdAPPatchInfo = "java -cp #{cmdAPClasspath} " \<br />
+ "com.tacitknowledge.util.migration.jdbc.MigrationInformation </code><code>#{systemName}</code><code>"<br />
system(cmdAPPatchInfo)<br />
end</code></p>
<p><code>desc "Apply database migrations."<br />
task :dbmigrate do<br />
cmdAPClasspath = "#{deployDir}/applications/database/lib/oracle/ojdbc14_g.jar" \<br />
+ ":#{deployDir}/dist/prepare/database" \<br />
+ ":#{deployDir}/lib/java/tk-autopatch-1.2-b-cvs.jar" \<br />
+ ":#{deployDir}/lib/java/log4j-1.2.8.jar" \<br />
+ ":#{deployDir}/lib/java/commons-logging-1.0.3.jar" \<br />
+ ":#{deployDir}/lib/java/commons-collections-3.2.1.jar" \<br />
+ ":#{deployDir}/lib/java/commons-lang-2.2.jar" \<br />
+ ":#{deployDir}/lib/java/tk-util-1.1.2.jar"<br />
cmdAPPatch<code>I</code>nfo = "java -cp #{cmdAPClasspath} " \<br />
+ "com.tacitknowledge.util.migration.jdbc.StandaloneMigrationLauncher #{systemName}"<br />
system(cmdAPPatchInfo)<br />
end</code></p>
<div class="tweetthis" style="text-align:left;"><p> <a class="tt" href="http://twitter.com/home/?status=Automate+your+non-rails+db+migrations+with+Capistrano+and+AutoPatch+http%3A%2F%2Ftinyurl.com%2F3ly257l" title="Post to Twitter"><img class="nothumb" src="http://www.codedrop.ca/blog/wp-content/plugins/tweet-this/icons/en/twitter/tt-twitter.png" alt="Post to Twitter" /></a> <a class="tt" href="http://twitter.com/home/?status=Automate+your+non-rails+db+migrations+with+Capistrano+and+AutoPatch+http%3A%2F%2Ftinyurl.com%2F3ly257l" title="Post to Twitter">Tweet This Post</a></p></div>]]></content:encoded>
			<wfw:commentRss>http://www.codedrop.ca/blog/archives/191/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

