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

Fire events on migrations #854

Closed
alexbowers opened this issue Oct 22, 2017 · 7 comments

Comments

Projects
None yet
2 participants
@alexbowers
Copy link

commented Oct 22, 2017

Can we have events fired in Migrations?

I'm thinking:

  • migrations.before
  • migrations.after
  • migrations:refresh.before
  • migrations:refresh.middle
  • migrations:refresh.after

etc.

This would allow for things like clearing of the cache when the migrations are being fired.

A use case i've come across is some of our migrations have data populated for User groups and their roles (using spatie laravel permissions).

When trying to run a migrate:refresh it will fail on the migrate half of it, because of how the caching is setup by default in spatie laravel permissions.

Even though the data is all deleted, it throws exceptions on create attempts because the cache still exists.

I'd like to be able to catch the "after truncate" bit, and clear the cache so that populate works.

There are also use cases for this in production too, such as sending a notification to a monitoring service whenever a migration has been ran, to help track performance metrics before / after migrations etc.

@alexbowers

This comment has been minimized.

Copy link
Author

commented Aug 30, 2018

@taylorotwell I can open a PR to do this, but if possible i'd like feedback about whether you have any immediate objections to this.

@ttomdewit

This comment has been minimized.

Copy link

commented Apr 25, 2019

@alexbowers Were you able to find a solution in the mean time? I'd be rather thrilled to have such events which I can subscribe to.

@alexbowers

This comment has been minimized.

Copy link
Author

commented Apr 25, 2019

I never found a solution to this, I instead changed how our code worked

@ttomdewit

This comment has been minimized.

Copy link

commented Apr 25, 2019

@alexbowers Thats fair enough. I’ve mentioned @driesvints on Twitter and he mentioned they’d appreciate a PR but the final decision lies with @taylorotwell. I’d appreciate such an addition so I might take this upon myself to PR the desired changes.

@alexbowers

This comment has been minimized.

Copy link
Author

commented Apr 25, 2019

@ttomdewit Have you started on this? If not, I can do it this evening.

@ttomdewit

This comment has been minimized.

Copy link

commented Apr 25, 2019

@alexbowers If you’re available, please. I don’t have the time this week.

@alexbowers

This comment has been minimized.

Copy link
Author

commented Apr 25, 2019

@ttomdewit PR sent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.