Commits

Anonymous committed fe8fb50

fixed nomads code

  • Participants
  • Parent commits 8b75ac0

Comments (0)

Files changed (1)

File _posts/2010-12-26-nomads.md

 In either case I wanted the developer to have as much liberty as she can get.
 So lambda the ultimate to the rescue. In fact the migration files are read and evaluated inside a quasiquote. If the library recognizes that the body of a migration holds a procedure, it invokes it and passes the database-adapter as its sole argument.
 
-~~~
+~~~clojure
 ((UP ,(lambda (db) (do-something-nifty-with db)))
  (DOWN ,(lambda (db) (undo-something-nifty-with db))))
 ~~~
 ## The nomads in us(e)
 
 Now that I had the overall architecture, I was able to implement what I needed. This was a lot of fun actually.
-'''Peter Bex''' from '''#chicken''' came up with the cool name nomads for the library; 
+'''Peter Bex''' from '''#chicken''' came up with the cool name nomads for the library;
 and having a name hacking became even more fun. I implemented some more stuff which I found useful. Some of the features I'm going to outline here, for the entire functionality check out the [nomads documentation](http://wiki.call-cc.org/eggref/4/nomads).
 
 ### The versioning scheme
 
 Another common feature are migrations, that aren't reversible. Of course the library allows to express this situation. The migration file may simply hold #f to be considered irreversible. The developer can also add an optional message for irreversible migrations.
 
-~~~
+~~~clojure
 ((UP "CREATE TABLE vertices (id INTEGER, name STRING)")
  (DOWN (#f . "You must not remove vertices") ))
 ~~~
 
 Now we can put it all together and create a simple program that can be used to manage the migrations. Here is a simple version that works like RoRs db:migrate rake task. It uses a custom callback that is invoked on each check point, which enables us to customize the way we report migrations. We're using Alex Shin's very cool [fmt egg](http://wiki.call-cc.org/eggref/4/fmt) to do so.
 
-~~~
+~~~clojure
 (use nomads nomads-sql-de-lite fmt fmt-color filepath)
 
 (migration-directory "./migrations")
 
 
 All you need to do is adjust the path to your database and compile the program like this:
-<pre class="prettyprint linenums">
- $ csc migrate.scm
-</pre>
+
+~~~
+  $ csc migrate.scm
+~~~
 
 Now you can use it like this:
-<pre class="prettyprint linenums">
+
+~~~
  $ VERSION=3 migrate
-</pre>
+~~~
 This was it! Check out CHICKEN and nomads if you like. Also have a look at all the other great eggs. Or better yet, provide some more.
-
-
-
-