Skip to content

Commit

Permalink
[#240] Fix broken cli cals - pass config instead of store
Browse files Browse the repository at this point in the history
  • Loading branch information
ieugen committed May 20, 2024
1 parent 298e927 commit 4523046
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions examples/postgres/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Commands with migratus

```shell

cd examples/postgres
# We export the configuration as env variable, but we can use cli or file as well
export MIGRATUS_CONFIG='{:store :database :db {:jdbcUrl "jdbc:postgresql://localhost:5432/migratus_example_db?user=postgres&password=migrate-me"}}'

Expand Down
23 changes: 12 additions & 11 deletions src/migratus/cli.clj
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,11 @@
"Migratus API does not support this action(s) : " arguments "\n\n"
(str/join (usage summary))))

(defn run-migrate! [cfg args]
(defn run-migrate! [store args]
(let [cmd-opts (parse-opts args migrate-cli-options :in-order true)
{:keys [options arguments errors summary]} cmd-opts
rest-args (rest arguments)]

rest-args (rest arguments)
cfg (proto/config store)]
(cond
errors (error-msg errors)
(:until-just-before options)
Expand All @@ -299,10 +299,11 @@
(migratus/migrate cfg))
:else (no-match-message args summary))))

(defn run-rollback! [cfg args]
(defn run-rollback! [store args]
(let [cmd-opts (parse-opts args rollback-cli-options :in-order true)
{:keys [options arguments errors summary]} cmd-opts
rest-args (rest arguments)]
rest-args (rest arguments)
cfg (proto/config store)]

(cond
errors (error-msg errors)
Expand Down Expand Up @@ -465,23 +466,23 @@
(.removeHandler main-logger h))
(.addHandler main-logger handler))))

(defn run-up! [cfg args]
(defn run-up! [store args]
(if (empty? args)
(println-err
"To run action up you must provide a migration-id as a parameter:
up <migration-id>")
(->> args
(map #(my-parse-long %))
(apply migratus/up cfg))))
(apply migratus/up (proto/config store)))))

(defn run-down! [cfg args]
(defn run-down! [store args]
(if (empty? args)
(println-err
"To run action down you must provide a migration-id as a parameter:
down <migration-id>")
(->> args
(map #(my-parse-long %))
(apply migratus/down cfg))))
(apply migratus/down (proto/config store)))))

(defn format-status-line
"Format transaction status line"
Expand Down Expand Up @@ -570,8 +571,8 @@
(println-err (ex-data e)))))

(defn- run-init!
[cfg]
(migratus/init cfg))
[store]
(migratus/init (proto/config store)))

(defn do-print-usage
([summary]
Expand Down

0 comments on commit 4523046

Please sign in to comment.