gormigrate
gormigrate copied to clipboard
callback functions after successful migration
Hey, great work with this package so far. What I miss is a way to hook into a chain of migrations/rollbacks and execute some code after each successful migration. This could be used for example to report to current progress of the migrations.
What I have in mind is something like extending the Options struct as follows. The methods would be called after each migration step.
type Options struct {
// ...
AfterMigration func(m *Migration)
AfterRollback func(m *Migration)
}
If you are happy with that change, I can provide a PR for it.
Hi @SchiffFlieger,
I think that having a single function for Before and After may be better:
type Options struct {
// ...
WhileMigrating func(m *Migration, yield func())
}
Options{
// ...
WhileMigrating: func(m *Migration, yield func()) {
// Do something before
yield()
// Do something after
}
}
I'm not sure about how useful this is, though. I'd like to hear more opinions before adding this to the lib.