REQUEST A DEMO

Automating Deployment For Clairfy Using Rake

Gary posted recently on Automating Deployment For Clarify. A customer recently had an automation need that I answered in a similar way but rather than using NAnt I pulled from our fancy favorite new build automation tool Rake. In this post we’ll take a look at automating common database setup tasks like applying schema scripts and executing arbitrary SQL using Rake. I hope you find it useful.

Where is the Code?

I put together a Dovetail Automation gist with everything you need to solve two problems.

  1. Applying  Dovetail Schema Editor schema scripts.
  2. Applying all SQL scripts in a directory.

Check out the readme for setup and execution instructions. Next I’ll talk a little about what each task does.

Applying Schema Scripts (apply_schemascripts)

This task looks for a child directory named schema below where the rakefile.rb is located. Every file in this directory ending in schemascript.xml will be applied to your target database.

Applying SQL Scripts (apply_sql)

This task looks for the child directory named database again below the current working directory. Every file ending in .sql is

Ordering

Both these tasks apply files to your database in the order they are found in the file system. This means you’ll want your scripts to be orthogonal to each other.

fork

I’ll leave it as an exercise to the reader to customize these scripts to follow a conventional file ordering. If you do fork the gist and let me know.

My Quick Argument For Rake over Nant

The main difference between to Nant and Rake is that NAnt encodes its behaviors using XML and Rake uses the scripting language Ruby. I am a self proclaimed NAnt Ninja but I do everything I can in Rake these days. Why? XML is pretty terrible at expressing useful behavior compared to a top shelf language like Ruby with lots of extensibility via its deep repository of Gems.

Comments

ADD COMMENT

Your email address will not be published.