backend: warning when started without DB_SEED

This commit is contained in:
Johannes Lötzsch 2022-03-11 17:10:07 +01:00
parent 73bdda8fa2
commit 1f5154e2af
3 changed files with 9 additions and 10 deletions

View File

@ -16,7 +16,7 @@
(s/def ::db-inmemory boolean?) ;; we run unit tests in an in-memory instance, otherwise the default db would be looked (s/def ::db-inmemory boolean?) ;; we run unit tests in an in-memory instance, otherwise the default db would be looked
(s/def ::db-dir string?) ;; ignored when ::db-inmemory (s/def ::db-dir string?) ;; ignored when ::db-inmemory
(s/def ::db-seed string?) ;; an edn-file to be used for seeding (s/def ::db-seed (s/nilable string?)) ;; an edn-file to be used for seeding
(s/def ::db-export-prefix (s/nilable string?)) ;; path where during startup an export should be written (s/def ::db-export-prefix (s/nilable string?)) ;; path where during startup an export should be written
(s/def ::db-validate boolean?) (s/def ::db-validate boolean?)

View File

@ -63,14 +63,13 @@
(export-named-by-date db_ctx "start") ;; before seeding (export-named-by-date db_ctx "start") ;; before seeding
(let [seed-file (when (not-empty (:db-seed env)) ;; There is no default seed file, to prevent loading it into the production system
(:db-seed env) (if (:db-seed env)
;; TODO configuration for tests (do (when (:verbose env)
#_(io/resource "beherbergung/db/seed/test.edn"))] (println "Seed the database from:" (:db-seed env)))
(when (:verbose env) (seed (:db-seed env) db_ctx))
(println "Seed the database from:" seed-file)) (println "WARNING: Seeding the database requires setting $DB_SEED"
(when seed-file "consider: DB_SEED=src/beherbergung/db/seed/test.edn"))
(seed seed-file db_ctx)))
(if (:db-validate env) (if (:db-validate env)
(or (validate-db db_ctx) (or (validate-db db_ctx)

View File

@ -6,7 +6,7 @@
:db-inmemory false :db-inmemory false
:db-dir "./data/xtdb/rocksdb" :db-dir "./data/xtdb/rocksdb"
:db-seed "" :db-seed nil
:db-export-prefix "./data/export/" :db-export-prefix "./data/export/"
:db-validate true :db-validate true