Skip to content

Commit

Permalink
patch: Reattempt to load migrations at runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
julienvincent committed Jan 22, 2024
1 parent 1f3133d commit 83bbfa1
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions packages/mallard/src/k16/mallard/loaders/fs.clj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
(re-find #"^\(ns\s+([^\s);]+)")
second))

(defn- resolve-migration-files [dir]
(defn resolve-migration-files [dir]
(->> (or (io/resource dir)
(io/file dir))
io/file
Expand All @@ -31,12 +31,15 @@
also allows loading of migrations when they are bundled as resources within a jar as the full resource
paths are known up front."
[dir]
(let [namespaces (resolve-migration-files dir)]
`(do (doseq [namespace# ~namespaces]
(require (symbol namespace#)))
(let [namespaces (try (resolve-migration-files dir)
(catch Exception _))]
`(let [namespaces# (or ~namespaces
(resolve-migration-files ~dir))]
(doseq [namespace# namespaces#]
(require (symbol namespace#)))

(->> ~namespaces
(map (fn [namespace#]
{:id (-> namespace# (str/split #"\.") last)
:run-up! (resolve (symbol (str namespace# "/run-up!")))
:run-down! (resolve (symbol (str namespace# "/run-down!")))}))))))
(->> namespaces#
(map (fn [namespace#]
{:id (-> namespace# (str/split #"\.") last)
:run-up! (resolve (symbol (str namespace# "/run-up!")))
:run-down! (resolve (symbol (str namespace# "/run-down!")))}))))))

0 comments on commit 83bbfa1

Please sign in to comment.