Created
March 1, 2018 13:40
-
-
Save igrishaev/40980671876d91721460bb2acea60abf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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