Skip to content

Commit 4523046

Browse files
committed
[#240] Fix broken cli cals - pass config instead of store
1 parent 298e927 commit 4523046

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

examples/postgres/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ Commands with migratus
9191

9292
```shell
9393

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

src/migratus/cli.clj

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,11 @@
283283
"Migratus API does not support this action(s) : " arguments "\n\n"
284284
(str/join (usage summary))))
285285

286-
(defn run-migrate! [cfg args]
286+
(defn run-migrate! [store args]
287287
(let [cmd-opts (parse-opts args migrate-cli-options :in-order true)
288288
{:keys [options arguments errors summary]} cmd-opts
289-
rest-args (rest arguments)]
290-
289+
rest-args (rest arguments)
290+
cfg (proto/config store)]
291291
(cond
292292
errors (error-msg errors)
293293
(:until-just-before options)
@@ -299,10 +299,11 @@
299299
(migratus/migrate cfg))
300300
:else (no-match-message args summary))))
301301

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

307308
(cond
308309
errors (error-msg errors)
@@ -465,23 +466,23 @@
465466
(.removeHandler main-logger h))
466467
(.addHandler main-logger handler))))
467468

468-
(defn run-up! [cfg args]
469+
(defn run-up! [store args]
469470
(if (empty? args)
470471
(println-err
471472
"To run action up you must provide a migration-id as a parameter:
472473
up <migration-id>")
473474
(->> args
474475
(map #(my-parse-long %))
475-
(apply migratus/up cfg))))
476+
(apply migratus/up (proto/config store)))))
476477

477-
(defn run-down! [cfg args]
478+
(defn run-down! [store args]
478479
(if (empty? args)
479480
(println-err
480481
"To run action down you must provide a migration-id as a parameter:
481482
down <migration-id>")
482483
(->> args
483484
(map #(my-parse-long %))
484-
(apply migratus/down cfg))))
485+
(apply migratus/down (proto/config store)))))
485486

486487
(defn format-status-line
487488
"Format transaction status line"
@@ -570,8 +571,8 @@
570571
(println-err (ex-data e)))))
571572

572573
(defn- run-init!
573-
[cfg]
574-
(migratus/init cfg))
574+
[store]
575+
(migratus/init (proto/config store)))
575576

576577
(defn do-print-usage
577578
([summary]

0 commit comments

Comments
 (0)