Skip to content

Create a schema for an existing unannotated CLOUD database from a REPL

Jarrod edited this page Sep 15, 2022 · 6 revisions

Include the schema cartographer library and the client api as a dependencies in your project.

Clojars Project

Then from a repl:

(ns your-namespace
  (:require
    [datomic.client.api :as d]
    [schema-cartographer.core :as cartographer]))

(def cfg-map {:server-type :ion
              :region "us-east-1"
              :system "your-system" ; <stack-name> also called <system-name>
              :endpoint "https://ClientApiGatewayEndpoint.execute-api.us-east-1.amazonaws.com"})

(def client (d/client cfg-map))
(def conn (d/connect client {:db-name "your-database"})))

;; Arguments to the save-explore-schema-edn
;; 1) `db` 
;; 2) `path` to save the resulting schema file to
;; 3) `ref-search-limit` This is the number of referenced entities to inspect when creating relationships maps can be `nil` for no limit. If `nil` this could take a LONG time for large databases
;; 4) `db-type` this should be :cloud
(cartographer/save-explore-schema-edn db "resources/db-schema.edn" 2000000 :cloud)

Progress will be logged to the repl while the utility is running.

Load the resulting output file in the UI that resides at https://schema-cartographer.com