This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-07
Channels
- # aleph (1)
- # beginners (152)
- # cider (26)
- # clara (2)
- # cljs-dev (13)
- # cljsrn (5)
- # clojure (198)
- # clojure-greece (15)
- # clojure-italy (39)
- # clojure-sanfrancisco (3)
- # clojure-spec (28)
- # clojure-uk (16)
- # clojurescript (52)
- # community-development (15)
- # core-async (26)
- # cursive (42)
- # data-science (28)
- # datomic (19)
- # devops (7)
- # duct (11)
- # emacs (24)
- # fulcro (22)
- # garden (4)
- # leiningen (12)
- # luminus (1)
- # mount (5)
- # off-topic (106)
- # om (5)
- # onyx (10)
- # parinfer (37)
- # re-frame (17)
- # reagent (47)
- # shadow-cljs (36)
- # yada (2)
I’m adding an integrant key for seeding my database, so that I can do lein run :my-ns/seeder
, similar to rake db:seed
. I know I can prevent it from being initialized automatically in production by not inheriting from :duct/daemon
; but is there a way to exclude it from initialization, even in development? I suppose I could filter it out in dev.clj
prior to (duct/read-config ..)
?
@dadair You can filter it out of the map, but a more robust solution would be to make it idempotent.
so more along the lines of having a (when (requires-seeds? db) (seed! db))
in the init-key handler?
Something like that. It ensures the seeding function is safe no matter how it’s applied. Ideally, if an old seed is applied, a newer seed should replace it.
It depends on how your database is set up, and whether the seed is constant between production and development.
You could use a migration for it if it was constant.
Initially it was a migration but we want to move it into proper clj files to have more programmatic control (lots of interrelated baseline records). I think your comment on idempotency is the correct approach.
A custom migration record might be a solution. So long as it satisfies the ragtime.protocols/Migration
protocol.
On the other hand, it might not be desirable to tie the seed to the migrations if they are sufficiently unrelated.
Great, thank you @weavejester