Fork me on GitHub
#luminus
<
2018-04-15
>
dviramontes17:04:48

Hi 👋:skin-tone-5: / looking for some guidance on a freshly scaffolded luminus app - lein new luminus <app> +cljs +http-kit +postgres +graphql +re-frame +sassc // Luminus version 2.9.11.14 I'm looking to add a migration but cant find the command to run, do i need to add migratus to my dependencies ? ive seen this elsewhere on the web but its not working locally lein migratus create foobar

dviramontes17:04:29

it looks like luminus can run migrations out of the box but not create them ? is that right ?

yogthos17:04:15

@dviramontes the latest version of the template moved to managing migrations from the REPL

yogthos17:04:43

the user namespace found in env/dev/clj/user.clj provides some helper functions for running and creating migrations

yogthos17:04:58

that's the default namespace the repl should load in

yogthos17:04:33

(defn reset-db []
  (migrations/migrate ["reset"] (select-keys env [:database-url])))

(defn migrate []
  (migrations/migrate ["migrate"] (select-keys env [:database-url])))

(defn rollback []
  (migrations/migrate ["rollback"] (select-keys env [:database-url])))

(defn create-migration [name]
  (migrations/create name (select-keys env [:database-url])))

yogthos17:04:46

the main reason is that clj runtime takes a while to warm up, so running stuff from the REPL is much faster

yogthos17:04:10

to make a migration you can just run (create-migration "foo") and it will create up/down files

dviramontes17:04:23

@yogthos gotcha, that makes / thanks!

dviramontes17:04:41

> (create-migration "foo") > IllegalArgumentException find not supported on type: mount.core.DerefableState clojure.lang.RT.find (RT.java:863)

dviramontes17:04:33

> user=> *ns* > #object[clojure.lang.Namespace 0x3961b716 "user"]

yogthos17:04:28

the database state has to be loaded, whenever you see mount.core.DerefableState errors it just means that the resource hasn't been initialized

dviramontes17:04:32

ahhh make sense!

yogthos17:04:36

to start it explicitly, you just have to run (mount.core/start #'<app>.db.core/*db*)

dviramontes17:04:58

i just ran (restart) and then (create-migration "foo") worked!

dviramontes17:04:05

thanks for much @yogthos!!!

yogthos17:04:15

this only happens until you actually start using the db in the app, once the namespace is referenced somewhere the state will be started automatically

4
yogthos17:04:18

no prob 🙂

4
eoliphant20:04:29

hi, I’m getting some werid issues creating new project the template doens’t seem to be paying attention to the options

yogthos23:04:23

@eoliphant could you give a bit more details on what's happening?

eoliphant23:04:46

sure, basically i seem to just get a default project. I even tried just cutting and pasting one of the examples from the site. It’s weird because I’ve used it dozens of times with no problem.

eoliphant23:04:14

and to be clear a default luminus project

yogthos23:04:51

oh that's odd

yogthos23:04:08

let me give that a shot locally

eoliphant23:04:53

yeah super. they’re just maven resoruces right? will try maybe deleting it from my local repo

yogthos23:04:11

hmm lein new luminus myapp +postgres +re-frame seem to do the right thing for me

eoliphant23:04:27

yeah maybe something local is hosed

yogthos23:04:29

and yeah doing rm -rf ~/.m2/repository/luminus/lein-template should clear the cached version

yogthos23:04:43

another thing to look at is ~/.lein/profiles.clj

eoliphant23:04:55

it’s not general though because I tried say the re-frame template with a couple options and it was fine.

eoliphant23:04:14

yeah I’ll nuke it and see what that does

yogthos23:04:26

the only thing I can think of is a really old version of the template pinned somewhere