Permalink
Browse files

Refactored part of append-to-mfile into the create-mfile function.

  • Loading branch information...
budu committed Aug 21, 2011
1 parent 07108f4 commit 343d788a8e17db4875df08e90027ec75698273f7
Showing with 19 additions and 15 deletions.
  1. +19 −15 src/lobos/migration.clj
View
@@ -145,22 +145,26 @@
(.replace "." "/")
(str ".clj"))))
+(defn create-mfile []
+ (append
+ (migrations-file)
+ `(~'ns ~*migrations-namespace*
+ (:refer-clojure :exclude [~'alter ~'defonce ~'drop
+ ~'bigint ~'boolean ~'char
+ ~'double ~'float ~'time])
+ (:use (~'lobos [~'migration :only [~'defmigration]]
+ ~'core ~'schema)
+ ~*config-namespace*))))
+
(defn append-to-mfile [name msg up & [down]]
- (let [mfile (migrations-file)]
- (when-not (.exists (migrations-file))
- (append mfile `(~'ns ~*migrations-namespace*
- (:refer-clojure :exclude [~'alter ~'defonce ~'drop
- ~'bigint ~'boolean ~'char
- ~'double ~'float ~'time])
- (:use (~'lobos [~'migration :only [~'defmigration]]
- ~'core ~'schema)
- ~*config-namespace*))))
- (append
- mfile
- `(~'defmigration ~name ~@(when msg [msg])
- (~'up [] ~@up)
- ~@(when down
- [`(~'down [] ~@down)])))))
+ (when-not (.exists (migrations-file))
+ (create-mfile))
+ (append
+ (migrations-file)
+ `(~'defmigration ~name ~@(when msg [msg])
+ (~'up [] ~@up)
+ ~@(when down
+ [`(~'down [] ~@down)]))))
(defn list-migrations []
(when (.exists (migrations-file))

0 comments on commit 343d788

Please sign in to comment.