Awesome
The development of this library has been discontinued.
The liquibase-sbt-plugin is a plugin for the Simple Build Tool (SBT) for running LiquiBase commands.
This version only supports SBT 0.7.x.
Liquibase is a database-independent library for tracking, managing and applying database changes.
#Setup#
-
Define a dependency on the liquibase-sbt-plugin in your plugin definition file,
project/plugins/Plugins.scala
import sbt._ class Plugins(info: ProjectInfo) extends PluginDefinition(info) { val liquibaseSbtSnapshots = "Liquibase SBT Snapshots Repository" at "http://sdb.github.com/maven/snapshots" val liquibase = "com.github.sdb" % "liquibase-sbt-plugin" % "0.0.1-SNAPSHOT" }
-
Mixin the LiquibasePlugin trait in your project file, e.g.
project/build/TestProject.scala
import sbt._ import com.github.sdb.sbt.liquibase.LiquibasePlugin class TestProject(info: ProjectInfo) extends DefaultProject(info) with LiquibasePlugin { ... }
-
Configure
class TestProject(info: ProjectInfo) extends DefaultProject(info) with LiquibasePlugin { // declare the required database driver as a runtime dependency val h2 = "com.h2database" % "h2" % "1.2.143" % "runtime" // provide the parameters for running liquibase commands lazy val liquibaseChangeLogFile = "config" / "db-changelog.xml" lazy val liquibaseDriver = "org.h2.Driver" lazy val liquibaseUrl = "jdbc:h2:mem:" // provide username and password for database access override lazy val liquibaseUsername = "sa" override lazy val liquibasePassword = "" }
Note that this a very basic way to configure the plugin. Take a look at this gist for a more realistic example.
#Usage#
The following actions are available:
-
liquibase-update
Applies un-run changes to the database.
-
liquibase-update-count COUNT
Applies the next number of change sets.
-
liquibase-drop [SCHEMA]...
Drops database objects owned by the current user.
-
liquibase-tag TAG
Tags the current database state for future rollback.
-
liquibase-rollback TAG
Rolls back the database to the state it was in when the tag was applied.
-
liquibase-rollback-count COUNT
Rolls back the last number of change sets.
-
liquibase-rollback-date DATE
Rolls back the database to the state it was in at the given date/time. The format of the date must match that of 'liquibaseDateFormat'.
-
liquibase-validate
Checks the changelog for errors.
-
liquibase-clear-checksums
Removes current checksums from database.