From 9e6d900596c07ef4a8143212ac42dbcaca3f2956 Mon Sep 17 00:00:00 2001 From: Nicholas Kariniemi Date: Sat, 4 Jul 2015 23:01:19 +0300 Subject: [PATCH] Hard-code database schema in database namespace - Loading it separately doesn't make sense for e.g. production builds. --- database_schema.edn | 53 -------------------------------------------- src/clj/grub/db.clj | 54 ++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 54 deletions(-) delete mode 100644 database_schema.edn diff --git a/database_schema.edn b/database_schema.edn deleted file mode 100644 index 68d89b7..0000000 --- a/database_schema.edn +++ /dev/null @@ -1,53 +0,0 @@ -[ - ;; grubs - {:db/id #db/id[:db.part/db] - :db/ident :grub/id - :db/valueType :db.type/keyword - :db/cardinality :db.cardinality/one - :db/unique :db.unique/identity - :db/doc "Grub ID" - :db.install/_attribute :db.part/db} - {:db/id #db/id[:db.part/db] - :db/ident :grub/text - :db/valueType :db.type/string - :db/cardinality :db.cardinality/one - :db/fulltext true - :db/doc "The text of a grub item e.g. '3 apples'" - :db.install/_attribute :db.part/db} - {:db/id #db/id[:db.part/db] - :db/ident :grub/completed - :db/valueType :db.type/boolean - :db/cardinality :db.cardinality/one - :db/doc "The status of a grub item (completed or not completed)" - :db.install/_attribute :db.part/db} - - ;; recipes - {:db/id #db/id[:db.part/db] - :db/ident :recipe/id - :db/valueType :db.type/keyword - :db/cardinality :db.cardinality/one - :db/unique :db.unique/identity - :db/doc "Recipe ID" - :db.install/_attribute :db.part/db} - {:db/id #db/id[:db.part/db] - :db/ident :recipe/name - :db/valueType :db.type/string - :db/cardinality :db.cardinality/one - :db/fulltext true - :db/doc "Recipe name" - :db.install/_attribute :db.part/db} - {:db/id #db/id[:db.part/db] - :db/ident :recipe/grubs - :db/valueType :db.type/string - :db/cardinality :db.cardinality/one - :db/fulltext true - :db/doc "Recipe ingredients" - :db.install/_attribute :db.part/db} - {:db/id #db/id[:db.part/db] - :db/ident :recipe/directions - :db/valueType :db.type/string - :db/cardinality :db.cardinality/one - :db/fulltext true - :db/doc "Directions for making a recipe" - :db.install/_attribute :db.part/db} - ] diff --git a/src/clj/grub/db.clj b/src/clj/grub/db.clj index d18dfd6..b5b5afc 100644 --- a/src/clj/grub/db.clj +++ b/src/clj/grub/db.clj @@ -3,7 +3,59 @@ [clojure.core.async :as a :refer [! chan go]] [grub.util :as util])) -(def schema-tx (read-string (slurp "database_schema.edn"))) +(def schema-tx [ + ;; grubs + {:db/id #db/id[:db.part/db] + :db/ident :grub/id + :db/valueType :db.type/keyword + :db/cardinality :db.cardinality/one + :db/unique :db.unique/identity + :db/doc "Grub ID" + :db.install/_attribute :db.part/db} + {:db/id #db/id[:db.part/db] + :db/ident :grub/text + :db/valueType :db.type/string + :db/cardinality :db.cardinality/one + :db/fulltext true + :db/doc "The text of a grub item e.g. '3 apples'" + :db.install/_attribute :db.part/db} + {:db/id #db/id[:db.part/db] + :db/ident :grub/completed + :db/valueType :db.type/boolean + :db/cardinality :db.cardinality/one + :db/doc "The status of a grub item (completed or not completed)" + :db.install/_attribute :db.part/db} + + ;; recipes + {:db/id #db/id[:db.part/db] + :db/ident :recipe/id + :db/valueType :db.type/keyword + :db/cardinality :db.cardinality/one + :db/unique :db.unique/identity + :db/doc "Recipe ID" + :db.install/_attribute :db.part/db} + {:db/id #db/id[:db.part/db] + :db/ident :recipe/name + :db/valueType :db.type/string + :db/cardinality :db.cardinality/one + :db/fulltext true + :db/doc "Recipe name" + :db.install/_attribute :db.part/db} + {:db/id #db/id[:db.part/db] + :db/ident :recipe/grubs + :db/valueType :db.type/string + :db/cardinality :db.cardinality/one + :db/fulltext true + :db/doc "Recipe ingredients" + :db.install/_attribute :db.part/db} + {:db/id #db/id[:db.part/db] + :db/ident :recipe/directions + :db/valueType :db.type/string + :db/cardinality :db.cardinality/one + :db/fulltext true + :db/doc "Directions for making a recipe" + :db.install/_attribute :db.part/db} + ]) (defn add-schema-to-db [uri] (d/transact (d/connect uri) schema-tx) )