Commits

Anonymous committed 5c4c0c4

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

Comments (0)

Files changed (4)

 
 # 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.
-(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"]])

src/leiningen/lb.clj

 (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
     (cond
       (empty? args)                (help)
       (= cmd ":help")              (help)
       (= cmd ":sample-properties") (sample-props)
-      :else                        (execute-liquibase-cmd argv))))
+      :else                        (apply execute-liquibase-cmd args))))

src/liquibase.properties

 
 ## ----- Required Parameters -----
 
-## Migration file
+## Migration file (XML)
 #changeLogFile=<path and filename>
 
 ## Database username
 
 ## Output data as CSV in the given directory
 #dataOutputDirectory=DIR
+
+
+## ----- Canned properties for different databases -----
+
+## MySQL
+#username=dbuser
+#password=secret
+#url=jdbc:mysql://localhost:3306/exampledb
+#driver=com.mysql.jdbc.Driver
+#defaultSchemaName=exampledb
+
+
+## PostgreSQL: s
+#username=dbuser
+#password=secret
+#url=jdbc:postgresql://localhost:5432/exampledb
+#driver=org.postgresql.Driver
+#defaultSchemaName=exampledb
+
+
+## Sybase
+#username=dbuser
+#password=secret
+#url=jdbc:jtds:sybase://localhost:7100/exampledb
+#driver=org.postgresql.Driver
+#defaultSchemaName=exampledb
+
+
+## MS SQL Server
+#username=dbuser
+#password=secret
+#url=jdbc:jtds:sqlserver://localhost:1433/exampledb
+#driver=org.postgresql.Driver
+#defaultSchemaName=exampledb