Skip to content

Adding a new database type

Martin Trojer edited this page Sep 9, 2015 · 8 revisions

To introduce a new database type into Joplin there are 2 interfaces you need to implement. This is typically done in a single database.clj file with a namespace prefix containing the name of the database, i.e. joplin.cassandra.database.

The ragtime interface

The ragtime DataStore protocol contains three functions signatures. Implementing them is usually straight forward, see the joplin.cassandra project.

The joplin interface

The joplin interface consist of 5 multi-methods, they all share the same signature [target & args] and dispatch on (get-in target [:db :type]).

The target map will consist of 3 keys; :db, :migrator, :seed. They are filled in by the joplin leiningen plugin or by the caller in joplin is used programatically.

  • migrate-db Migrate target database described by a joplin database map.

  • rollback-db Rollback target database described by a joplin database map N steps. N is an optional argument and if present should be the first in args.

  • seed-db Write seed data to target database described by a joplin database map.

  • pending-db Get a list of pending migrations.

  • create-migration Create migrations file(s) for target database described by a joplin database map. The first argument must be the name of the migration to create"

There are various helper functions in joplin.core that should make writing them simple, see the joplin.cassandra project.