Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callback functions after successful migration #52

Open
karstenkoehler opened this issue Nov 3, 2020 · 1 comment
Open

callback functions after successful migration #52

karstenkoehler opened this issue Nov 3, 2020 · 1 comment

Comments

@karstenkoehler
Copy link

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.

@andreynering
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants