Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Clojure wrapper for Liquibase for database change management and migration
Clojure Java
branch: master

Merge pull request #5 from cgore/master

Fixed a few Liquibase doc URLs in the doc strings.
latest commit c901f98fe6
@kumarshantanu authored


Clj-Liquibase is a Clojure wrapper for Liquibase for database change management and migration.

Supported actions:

  • update
  • tag
  • rollback
  • generate SQL for actions
  • generate DB doc
  • database diff


On Clojars:

Leiningen dependency: [clj-liquibase "0.5.2"]


Create a new project e.g. fooapp using Leiningen and include the following dependencies in project.clj:

[clj-dbcp      "0.8.1"]  ; to create connection-pooling DataSource
[clj-liquibase "0.5.2"]  ; for this library
[oss-jdbc      "0.8.0"]  ; for Open Source JDBC drivers

Create a Clojure source file for managing the DB schema. Include the required namespaces define the change, changeset and changelog objects:

(ns fooapp.dbschema
    [clj-dbcp.core        :as cp]
    [clj-liquibase.change :as ch]
    [clj-liquibase.cli    :as cli])
    [clj-liquibase.core :only (defchangelog)]))

;; define the changes, changesets and the changelog

(def ct-change1 (ch/create-table :sample-table1
                  [[:id     :int          :null false :pk true :autoinc true]
                   [:name   [:varchar 40] :null false]
                   [:gender [:char 1]     :null false]]))

; recommended: one change per changeset
(def changeset-1 ["id=1" "author=shantanu" [ct-change1]])

; you can add more changesets later to the changelog
(defchangelog app-changelog "fooapp" [changeset-1])

;; keep the DataSource handy and invoke the CLI

(def ds (cp/make-datasource :mysql {:host "localhost" :database "people"
                                    :user "dbuser"    :password "s3cr3t"}))

(defn -main
  [& [cmd & args]]
  (apply cli/entry cmd {:datasource ds :changelog  app-changelog}

After defining the changelog, you need to apply the changes:

lein run -m fooapp.dbschema help
lein run -m fooapp.dbschema update


For more documentation please refer the file doc/ in this repo.



Copyright © 2012-2014 Shantanu Kumar and contributors

Distributed under the Eclipse Public License, the same as Clojure.

Something went wrong with that request. Please try again.