-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
I have found these related issues/pull requests
I have not found any similar feature request.
Description
Right now Migrator::run returns (), meaning the only thing you know after running migrations is that it didn't fail.
In particular, the method provides no information about:
- If any migrations actually ran at all.
- How many migrations ran.
- Which migrations ran.
This information could be useful for diagnostics and observability.
Prefered solution
A simple solution that gives at least a bit more information: Make Migrator::run return usize instead of (), where the return value is the number of migrations run. This doesn't cover use case number 3 above though.
A better solution which is probably also more future-proof would be returning some form of collection, probably of Migration? I.e. basically a Vec<Migration> containing all the migrations that was run (in the order they were run). Maybe it would even be possible to just return a subslice of those that were run, i.e. return &[Migration]?
Is this a breaking change? Why or why not?
It could be, if Migrator::run changes. A non-breaking way to do this would be to implement a new function, called maybe something like run_info which implements this, and then simply implement run in terms of run_info, but discard the return value, which would preserve the current behavior while allowing opting in to the new behavior..