A Leiningen plugin to validate that a database migrated by tern is at the expected schema version level for the library that uses it.
[cc.artifice/tern-validate "1.0.0"]
into the :plugins
vector of the project.clj file for the project that uses tern.lein install
) or run under the repl (lein repl
).tern-validate.core/validate2
, which will return true
or false
. The function takes a map as its sole parameter, with these keys
(:version (first (select :schema_versions (fields :version) (order :version :DESC) (limit 1))))
:tern
entry (a map) with a :validation
entry. If there is a :validation
entry, it should be a map containing :min-version
and/or :max-version
values, as strings.Out of the box, tern-validate will tell you if the running database exactly matches the version number of the latest migration in
the migrations/
folder of the project that uses tern. You may add a :validation
key to the tern configuration in project,
which allows you to specify a range of versions that are acceptable to the library:
...
:tern {:migration-dir "migrations"
:version-table "schema_versions"
:validation {:min-version "20160627122211" :max-version "20160714092135"}}
...
If min or max version is missing, the acceptable version range is open-ended. If both are missing, the database version must exactly match the version of the latest migration.
At present, the migrations directory must be migrations/
, directly under the project directory.
Copyright © 2016, 2017 i2k Connect LLC
Distributed under the Eclipse Public License version 1.0.
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close