Skip to content

Instantly share code, notes, and snippets.

@igrishaev
Created March 1, 2018 13:40
Show Gist options
  • Save igrishaev/40980671876d91721460bb2acea60abf to your computer and use it in GitHub Desktop.
Save igrishaev/40980671876d91721460bb2acea60abf to your computer and use it in GitHub Desktop.
(defn- file-name
[^java.io.File file]
(.getName file))
(defn- is-sql?
[^java.io.File file]
(-> file file-name (s/ends-with? ".sql")))
(defn- to-migration
[^java.io.File file]
{:name (file-name file)
:body (slurp file)})
(defn- read-migrations
[^String res]
(if-let [mig-dir (-> res io/resource io/file)]
(->> mig-dir
file-seq
(filter is-sql?)
(sort-by file-name)
(map to-migration))
(throw (Exception.
(format "Cannot read migrations from: %s" res)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment