     (into (sorted-map)
           (select-keys migrations pending))))
 
-(defn- sql-or-die [f]
+(defn- sql-or-die
   "Calls (f) and returns its result.  If f throws an SQLException,
   logs the exception and its parent and then calls (System/exit 1)"
+  [f]
   ;; Here we've preserved existing behavior, but this may warrant
   ;; further consideration later.  If possible, we might want to
   ;; avoid System/exit in favor of careful exception

        ;; Make sure we're creating a new connection (the new
        ;; clojure.jdbc API will re-use an existing one).
        (assert (not (:connection db-connection-pool)))
        (jdbc/with-db-connection db-connection-pool
          (log/info "Analyzing database")
          (sql-or-die (fn []
                        (-> (doto (:connection (jdbc/db)) (.setAutoCommit true))
                            .createStatement
                            (.execute "vacuum (analyze, verbose)")))))))
    (log/info "There are no pending migrations")))

;; SPECIAL INDEX HANDLING


    (f)
    (catch java.sql.SQLException e
      (log/error e "Caught SQLException during migration")
      (when-let [next (.getNextException e)]
        (log/error next "Unravelled exception"))
      (binding [*out* *err*] (flush)) (flush)
      (System/exit 1))))

