Closed sirmspencer closed 1 year ago
That sounds reasonable, any chance you could do a quick PR for this?
I can't pull and test on my work computer, but this should do it.
(defn create [config name migration-type]
(let [migration-dir (find-or-create-migration-dir
(utils/get-parent-migration-dir config)
(utils/get-migration-dir config))
migration-name (->kebab-case (str (timestamp) name))]
(for [mig-file (proto/migration-files* migration-type migration-name)]
(let [file (io/file migration-dir mig-file)]
(.createNewFile file)
(.getName (io/file migration-dir mig-file))))))
ok cool, I just pushed out 1.5.1
with the fix
Woot, thanks!
Confirmed working.
If anyone else sees this, here is code that generates clj files per migration that match (except the NS can't start with a number so I prefixed with c for my use)
(defn new-consul-migration [title]
(let [new-fname (-> (mig/create (migratus-config db/db) title :edn)
(first))
new-ns (str/replace new-fname #".edn" "")]
(spit (str "resources/migrations/" new-fname)
(tus/->pprint-str {:ns (symbol (str "c-" new-ns))
:up-fn 'migrate-up
:down-fn 'migrate-down
:transaction? true}))
(spit (str "migrations/consul_migrations/c_"
(str/replace new-ns #"-" "_")
".clj")
(format "(ns c-%s)\n\n(defn migrate-up []\n)\n\n(defn migrate-down []\n)" new-ns))))
For code based migrations, other support files are needed which I can auto generate if I know the file name of the new migration file.