datomic-booties
datomic-booties copied to clipboard
stand up datomic databases with boot
datomic-booties
Dependency info:
[com.flyingmachine/datomic-booties "0.1.2"]
This library makes it easy to stand up a Datomic database with Boot. It provides the following tasks:
create-dbdelete-dbmigrate-dbruns migrations as described belowbootstrap-dbcombinescreate-dbandmigate-dbrecreate-dbcombinesdelete-dbandbootstrap-db
Migrations
datomic-booties looks for a db/schema.edn resource to define
database attributes; see the
conformity README for
details on how to structure db/schema.edn. Example schema:
{:booties/initial-schema
{:txes [[{:db/ident :user/username
:db/id #db/id [:db.part/db]
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/index true
:db/fulltext true
:db.install/_attribute :db.part/db}
;; posts
{:db/ident :post/content
:db/id #db/id[:db.part/db]
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/fulltext true
:db/doc "Post content"
:db.install/_attribute :db.part/db}
;; content
{:db/ident :content/author
:db/id #db/id[:db.part/db]
:db/valueType :db.type/ref
:db/cardinality :db.cardinality/one
:db/doc "General author attribute"
:db.install/_attribute :db.part/db}]]}}
It looks in db/seed.edn for seed data. See the
growmonster README for
details on seed data format.
Example:
[:users
[:billy
{:db/id #db/id [:db.part/user]
:user/username "billy"}]
:posts
[{:db/id #db/id [:db.part/user]
:post/content "post content"
:content/author [:users :billy :db/id]}]]
Example
In the build.boot of your project:
(set-env!
:resource-paths #{"resources"} ; this is where db/schema.edn and db/seed.edn live
:dependencies [[com.flyingmachine/datomic-booties "0.1.0"]])
;; This is necessary to read datomic literals like #db/id [:db.part/user]
(load-data-readers!)
(require
'[com.flyingmachine.datomic-booties.tasks :refer :all])
Then, from the terminal, run things like
$ boot bootstrap-db -u "datomic:free://localhost:4334/datomic-booties-dev"