lobos icon indicating copy to clipboard operation
lobos copied to clipboard

migrate does not work if lein project :src-paths set to something other than "src/"

Open intronic opened this issue 13 years ago • 5 comments

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

intronic avatar Apr 15 '13 06:04 intronic

was having the same problem & this fixed it... maybe if i or someone else finds some time a patch will mysteriously appear! :smile:

serialhex avatar Jul 29 '13 19:07 serialhex

+1 I have the same problem !

jeremieca avatar Jan 13 '14 18:01 jeremieca

Is this fix still relevant ? In my setup the src-directory variable is not defined...

phtrivier avatar Sep 17 '14 21:09 phtrivier

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

dvcrn avatar Dec 09 '14 07:12 dvcrn

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.

lynndylanhurley avatar Jan 11 '15 02:01 lynndylanhurley