migrate does not work if lein project :src-paths set to something other than "src/"
Hi,
This took me ages to figure out. (migrate) was not working following the example code. eg, migrate always returned nil, doing nothing:
user> (migrate)
nil
I found out that (migrate) calls (list-migrations) calls ns-file which uses *src-directory* to build a path to your migrations.clj file, so if you have non-default :src-paths you will need to bind *src-directory* to your path before calling migrate, and then your migrations will work:
user> (binding [*src-directory* "src/clojure/"] (migrate))
your-migration1-runs-now
your-migration2-runs-now
nil
My project.clj has these lines, which were the cause of the problem:
:source-paths ["src/clojure"]
:java-source-paths ["src/java"]
Its not exacltly a bug, and I dont know if its possible that lobos could find the actual src path, but maybe this note helps someone else.
Cheers
Mike
was having the same problem & this fixed it... maybe if i or someone else finds some time a patch will mysteriously appear! :smile:
+1 I have the same problem !
Is this fix still relevant ? In my setup the src-directory variable is not defined...
I am running into a similar problem and was wondering why no migrations are running. Turns out this is related. I am having clj/ and cljs/ under my src/ directory.
(binding [lobos.migration/*src-directory* "src/clj/"] (lobos.core/migrate)) solved it for me as well. Thanks for the tip, took me forever to figure this one out
I have the same issue. I'm using:
- clojure 1.6.0
- lobos 1.0.0-beta3
(binding [lobos.migration/*src-directory* "src/clj/"] (lobos.core/migrate)) solved it for me as well.