Fork me on GitHub
#luminus
<
2017-05-05
>
curlyfry15:05:07

Just read through http://www.luminusweb.net/docs/migrations.md and found this passage:

The migrations will be packaged in the applications when it's compiled. This allows the application to apply its own migrations when deployed to the server:

lein uberjar
java -jar target/uberjar/<app>.jar migrate
I noticed that the Procfile doesn't have migrate at the end of the command. What is the recommended way of automatically performing migrations when deploying (to for example Heroku)?

codefinger16:05:11

@curlyfry i would recommend one of two ways

codefinger16:05:54

you put a release: java -jar target/uberjar/<app>.jar migrate in your Procfile and it automatically runs in it's own dyno after a deploy

codefinger16:05:36

or you can run it on demand with $ heroku run java -jar target/uberjar/<app>.jar migrate. But you'd have to ensure that your new code can run momentarily w/ the old schema (or accept a period of downtime)

curlyfry16:05:12

@codefinger Awesome, thanks a lot! I'm using migratus-lein, so I'll probably go with release: lein migratus migrate

codefinger16:05:36

@curlyfry hmm, one problem with that is making sure the lein env is available at runtime. by default it's not, and you might end up re-downloading all dependencies

codefinger16:05:12

i tend to recommend the java -jar approach for running stuff other than the build

codefinger16:05:31

but you can $ heroku config:set LEIN_INCLUDE_IN_SLUG=yes

codefinger16:05:44

it will increase the size of your slug significantly though

codefinger16:05:56

(because it keeps the .m2 dir)

curlyfry16:05:17

Interesting! So I would simply run just the migration code and then exit when the program gets migrate as an argument? (Can't check right now of that is how it's done in Luminus)

codefinger16:05:59

@curlyfry yea. i'm looking at migratus now (i'm not familiar with it). It is very lein centric. other frameworks make it a little easier to run from code, such as flyway https://devcenter.heroku.com/articles/running-database-migrations-for-java-apps#running-flyway-with-the-java-api

codefinger16:05:09

I'm sure it's possible. I'll see if i can make an example

codefinger16:05:54

@curlyfry oh yea, totally. that's the ticket

curlyfry16:05:36

That seems simple enough. Release phase looks really useful!

curlyfry16:05:23

My only annoyance now is that I can't seem to figure out if I will need to duplicate my migratus config if I wan't to use it both from leiningen and from code

yogthos16:05:39

Yeah migratus can definitely be used outside lein

codefinger16:05:45

@curlyfry it's still in beta, so i'd love to know how it works for you so we can improve the UX as needed (I work at Heroku). the output is a little hard to find (you might need to look in http://dashboard.heroku.com)

yogthos16:05:27

I would recommend just updating the main function in the core namespace of the app to run migrations based on on env flag

yogthos16:05:08

Tht way you can set a prod env flag for that and have them run when the app starts

yogthos17:05:03

My recommendation is to always run migrations from code both in dev and in prod

yogthos17:05:16

That way you don't have any surprises

curlyfry17:05:51

@yogthos So your recommendation would be to (in -main): 1. Run migrations if a prod env flag is set, and 2. init the app as usual?

curlyfry17:05:30

I'll explore both options, thanks again @codefinger and @yogthos!

kahunamoore20:05:52

Running Luminus server/client (term1: lein repl (start), term2: lein figwheel) and am able to connect to the server, pull down the /docs and figwheel displays the repl prompt. Everything works great except figwheel doesn’t compile/hot-reload changed files.Looking at the chrome debugger sources pane I see that the same handlers.cljs lists one handlers.js file and server other handlers.js?zx=<some random string>

kahunamoore20:05:47

I’m guessing this is why the source maps aren’t pointing to the most recently compiled handlers.js file

kahunamoore20:05:08

This probably isn’t a luminus problem proper but maybe someone here has run across this before given that I generated this app using the luminus template.