1. Shantanu Kumar
  2. Lein-LB


shantanuk  committed 5c4c0c4

factor out run-liquibase-commands in a separate function
fix documentation

  • Participants
  • Parent commits b6f787b
  • Branches default

Comments (0)

Files changed (4)


View file
 # Lein-LB v0.1
-Leiningen plugin for [Liquibase](http://www.liquibase.org/): a database change management software.
+Leiningen plugin for [Liquibase: an RDBMS change management software](http://www.liquibase.org/).
 ## Usage
 Include Lein-LB as a dev dependency in project.clj:
-    :dev-dependencies [[org.bituf/lein-lb "0.1-SNAPSHOT"]]
+    :dev-dependencies [[org.bituf/oss-jdbc "0.2"] ; pulls OSS JDBC drivers
+                       [org.bituf/lein-lb  "0.1"]]
-And then
+and then,
     lein deps
     lein lb
-Ideally you would need to s
+Ideally you would store database/environment configuration inside the file
+./liquibase.properties file. An easy way to do that is to run this:
+    lein lb :sample-properties > liquibase.properties
+and then edit the file liquibase.properties as required.

File project.clj

View file
-(defproject org.bituf/lein-lb "0.1-SNAPSHOT"
+(defproject org.bituf/lein-lb "0.1"
   :description "Leiningen plugin for Liquibase: http://www.liquibase.org/"
-  :dependencies [[org.bituf/oss-jdbc           "0.1"]
-                 [org.liquibase/liquibase-core "2.0-rc6"]]
+  :dependencies [[org.liquibase/liquibase-core "2.0-rc6"]]
   :dev-dependencies [[org.clojure/clojure         "1.2.0"]
                      [org.clojure/clojure-contrib "1.2.0"]])

File src/leiningen/lb.clj

View file
 (ns leiningen.lb
   (:require [clojure.contrib.duck-streams :as ds]))
-(def *version* "0.1-SNAPSHOT (uses Liquibase 2.0-RC6)")
-;; DSL
+(def *version* "0.1 (uses Liquibase 2.0-RC6)")
 (defn help
     $ lein lb help
-Lein-LB commands (they all begin with a colon):
+For help on Lein-LB commands (notice that the command begins with a colon):
+    $ lein lb :help
+List of Lein-LB commands (they all begin with a colon):
     :help               prints this help screen
-    :sample-properties  prints sample properties to put in liquibase.properties
+    :sample-properties  prints sample properties - put in liquibase.properties
 (defn sample-props
   (let [filename "/liquibase.properties"
-        istream  (.getResourceAsStream String filename)
+        istream  (.getResourceAsStream String filename) ; returns InputStream
         owriter  (java.io.StringWriter.)]
-    ;; InputStream resourceAsStream = getClass().getResourceAsStream("/mypackage/mysubpackage/myfile.txt");
     (ds/copy istream owriter)
     (println (.toString owriter))))
 (defn execute-liquibase-cmd
   "Execute Liquibase as if using command-line arguments (String array)"
-  [argv]
-  (liquibase.integration.commandline.Main/main argv))
+  [& args]
+  (let [argv (into-array String args)]
+    (liquibase.integration.commandline.Main/main argv)))
 ;; ----- Leiningen plugin command -----
 (defn lb
   [& args]
   (let [argc (count args)
-        argv (into-array String args)
         cmd  (first args)]
     ;; check for lein-lb commands
       (empty? args)                (help)
       (= cmd ":help")              (help)
       (= cmd ":sample-properties") (sample-props)
-      :else                        (execute-liquibase-cmd argv))))
+      :else                        (apply execute-liquibase-cmd args))))

File src/liquibase.properties

View file
 ## ----- Required Parameters -----
-## Migration file
+## Migration file (XML)
 #changeLogFile=<path and filename>
 ## Database username
 ## Output data as CSV in the given directory
+## ----- Canned properties for different databases -----
+## MySQL
+## PostgreSQL: s
+## Sybase
+## MS SQL Server