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

Dispatch event when migration failed #1336

Open
maMykola opened this issue Apr 7, 2023 · 3 comments
Open

Dispatch event when migration failed #1336

maMykola opened this issue Apr 7, 2023 · 3 comments

Comments

@maMykola
Copy link

maMykola commented Apr 7, 2023

Feature Request

It would be useful to know if migration aborted due to some exception.

Q A
New Feature yes
RFC yes/no
BC Break no

Summary

There is a need to dispatch an event \Doctrine\Migrations\Events::onMigrationsAborted when exception happens during execution of migrations \Doctrine\Migrations\DbalMigrator::executeMigrations

@derrabus
Copy link
Member

derrabus commented Apr 9, 2023

What would be the use-case of such an event?

@maMykola
Copy link
Author

What would be the use-case of such an event?

I use ELK stack for logging and I want to know how frequently migrations were failed during deployment process and on which migration. So I need this type of event to create a listener.

@hvdklauw
Copy link

hvdklauw commented Jan 7, 2025

A usecase that I have and am trying to solve with this:

  • onMigrationsMigrating -> aquire a lock, if it's locked throw an error that migrations are already running
  • onMigrationsMigrated -> release the lock

This ensures only one instance of the migrations are running at the same time, except when an error occurs, then no migrations are run and you can't run them again till the lock is released.

Having a onMigrationsError event would help to catch that and also release the lock.

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

No branches or pull requests

3 participants