yogthos / migratus

MIGRATE ALL THE THINGS!
640 stars 95 forks source link

Custom args to migration functions #227

Closed wevre closed 1 year ago

wevre commented 1 year ago

Could we have additional args in the config map that will be passed to :up-fn and :down-fn? Something like this:

{:ns migratus.test.migration.edn.test-script-args
 :up-fn migrate-up
 :up-args ["hello-with-args.txt" "Hello, world, with args!"]
 :down-fn migrate-down
 :down-args ["hello-with-args.txt"]
 :transaction? true}

With custom args, the code-based migrations could potentially share namespaces and migration functions.

yogthos commented 1 year ago

I'd be open to this, another approach could be to have an optional vector syntax for up-fn, e.g: :up-fn [migrate-up "hello-with-args.txt" "Hello, world, with args!"]. Might be a bit more readable. If you'd be up to do a pr I'd be happy to help get that in.

wevre commented 1 year ago

Just submitted a PR.

yogthos commented 1 year ago

Thanks, looks good and just pushed out 1.4.3 with the feature.