                           [:state :text]
                           [:sha1 :text]
                           [:reason :text]
-                          [:timestamp :text])
+                          [:timestamp "integer not null default 0"])
         "CREATE UNIQUE INDEX `url_unique` ON `repo` (`url` ASC)"
         (create-table-ddl :achievement
                           [:id "integer primary key autoincrement"]


(defn- get-next-repo []
  (first (query db ["select * from repo 
    where strftime('%s','now') - strftime('%s', timestamp) > 4*60*60 or timestamp is null
    order by timestamp asc limit 1"])))

(defn- try-to-update [repo]
  (update! db :repo {:timestamp (.toLocaleString (java.util.Date.))} 
    ["id = ? and timestamp = ?" (:id repo) (:timestamp repo)]))

(defn get-next-repo-to-process []

        (logging/error e "Failed to initialize DB")))))

(defn add-fake-data []
  (insert! db :repo {:url "git@github.com:tonsky/datascript.git"})
  (insert! db :repo {:url "git@github.com:tonsky/41-socks.git"})
  (insert! db :repo {:url "git@github.com:tonsky/datascript-chat.git"})
  (insert! db :repo {:url "git@github.com:tonsky/net.async.git"})
  (insert! db :user {:name "Anders Hovmöller" :email "boxed@killingar.net"})
  (insert! db :user {:name "Bobby Calderwood" :email "bobby_calderwood@mac.com"})
  (insert! db :user {:name "Kevin J. Lynagh"  :email "kevin@keminglabs.com"})
