Ragtime is a Clojure library for migrating structured data in a way that's database independent. It defines a common interface for expressing migrations, much like Ring defines a common interface for expressing web applications.
Add the following dependency to your deps.edn file:
dev.weavejester/ragtime {:mvn/version "0.10.0"}
Or to your Leiningen project file:
[dev.weavejester/ragtime "0.10.0"]
Ragtime needs three pieces of data to work:
A data store is an implementation of the DataStore
protocol, and
tells Ragtime how to record which migrations are applied to an
arbitrary store of data, such as a database. It has three methods:
add-migration-id
- add a new migration ID to the storeremove-migration-id
- remove a migration ID from the storeapplied-migration-ids
- return an ordered list of applied IDSMigrations are implementations of the Migration
protocol, which also
has three methods:
id
- returns a unique ID for the migrationrun-up!
- applies the migration to a databaserun-down!
- rolls back the migration in a databaseRagtime comes with implementations of these protocols for Cloure's java.jdbc library and Sean Corfield's next.jdbc library, therefore supporting SQL migrations out of the box.
The migration store for SQL database is a special migrations table,
and the migrations can be specified as either .sql
files, or .edn
files. For more information, see the documentation below:
Copyright © 2024 James Reeves
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version
Can you improve this documentation? These fine people already did:
James Reeves, Max Shenfield, Juha Syrjälä & Thomas G. KristensenEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close