File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,28 @@ Since Migratus is a clojure library, we need to run it via clojure like this `cl
6464
6565There is also a bash script ` migratus.sh ` that does the same: ` ./migratus.sh --help `
6666
67+ #### Calling migratus via babashka task
68+
69+ We can use [ babashka] ( https://babashka.org/ ) tasks to drive migratus.
70+ This is usefull for creating developer and ops tooling.
71+
72+ Developers can easily create migrations from cli.
73+ Operations people can query the migration status on the server.
74+
75+ Bellow is a sample ` bb.edn ` file that calls the migratus alias in ` deps.edn ` , that we created earlier.
76+
77+ bb.edn
78+ ``` clojure
79+ ; ; example on how to call migrations via babashka
80+ {:tasks {:requires ([clojure.string :as str])
81+ migrate
82+ {:doc " Run migration tasks. Specify MIGRATUS_DB_SPEC to choose db."
83+ :task (clojure {:dir " ."
84+ :extra-env {" MIGRATUS_STORE" " database"
85+ " MIGRATUS_MIGRATION_DIR" " resources/migrations" }}
86+ (str/join " " (list* " -M:migratus" *command-line-args*)))}}}
87+
88+ ```
6789
6890Commands with migratus
6991
@@ -72,6 +94,9 @@ Commands with migratus
7294# We export the configuration as env variable, but we can use cli or file as well
7395export MIGRATUS_CONFIG=' {:store :database :db {:jdbcUrl "jdbc:postgresql://localhost:5432/migratus_example_db?user=postgres&password=migrate-me"}}'
7496
97+
7598clojure -M:migratus status
99+ # via bb
100+ bb migratus status
76101
77- ```
102+ ```
Original file line number Diff line number Diff line change 1+ ; ; example on how to call migrations via babashka
2+ {:tasks {:requires ([clojure.string :as str])
3+ migrate
4+ {:doc " Run migration tasks. Specify MIGRATUS_DB_SPEC to choose db."
5+ :task (clojure {:dir " ."
6+ :extra-env {" MIGRATUS_STORE" " database"
7+ " MIGRATUS_MIGRATION_DIR" " resources/migrations" }}
8+ (str/join " " (list* " -M:migratus" *command-line-args*)))}}}
You can’t perform that action at this time.
0 commit comments