          (filter (fn [x] (println (ns-name x)) (starts-with? (ns-name x) "db.migrations")))
          (sort #(before? (timestamp %1) (timestamp %2))))))
 
-
-(defn epoch-time
-  []
-  (quot (System/currentTimeMillis) 1000))
-
 (defn migrate
   [& rest]
-  (let [migrations (find-migrations)]
+  (let [migrations @migrations-lock]
     (if (empty? migrations)
-      (println "No migration found")
+      (warn "No migration found")
       (doseq [migration migrations]
         (println migration)))))
 
 (defn new-migrate
   [name & rest]
-  (println name)
   (let [epoch     (epoch-time)
         nsname    (str epoch "_" name)
         file-path (in-migrations (str nsname ".clj"))]
-    (println epoch)
-    (println nsname)
-    (println file-path)
+    (info "Creating migration file: " file-path)
     (spit file-path
-          (format migration_template nsname))))
+          (format migration_template nsname))
+    (info "Updating migrations lock file")
+    (update-lock nsname)))
 
 (defn wrong-command
   [cmd]
-  (println (format "Can't find the command '%s'." cmd)))
+  (error (format "Can't find the command '%s'." cmd)))
 
 (defn -main
   [command & rest]
-  (println command)
-  (println rest)
-  (println "<>")
+  (get-lock)
   (cond
     (= command "migration") (apply new-migrate rest)
     (= command "migrate")   (apply migrate rest)

            "  []"
            "  ;; Your code to teardown this migration, goes here"
            ")"))

(defn- is-timestamp?
  [value]

(ns hellhound.tasks.db
  (:require [hellhound.tasks.core :refer [in-migrations epoch-time long-str info error warn]]
            [clojure.string       :refer [ends-with? starts-with?]]
            [clojure.edn          :as edn]
            [clj-time.core        :refer [before?]]
            [clojure.java.io :as io]))

;; DEFINATIONS

;; Lock is not a great name i know, but i don't have
;; time to think about it
(def migrations-lock (atom []))
(def migration-lock-file (io/resource "migration.lock"))
(def migration_template
  (long-str "(ns db.migrations.%s)"
            ""
