Skip to content

Added property with file path to MigrationStarted and MigrationEnded migration events#55110

Closed
andrey-helldar wants to merge 1 commit intolaravel:12.xfrom
andrey-helldar:patch/2025-03-20/23-13
Closed

Added property with file path to MigrationStarted and MigrationEnded migration events#55110
andrey-helldar wants to merge 1 commit intolaravel:12.xfrom
andrey-helldar:patch/2025-03-20/23-13

Conversation

@andrey-helldar
Copy link
Contributor

The situation is very simple:

  1. Migration classes are anonymous;
  2. When sending the MigrationStarted and MigrationEnded events, which indicate the start and end of a particular migration, contain the migration instance itself and the start method - up or down;
  3. without the file parameter, it is impossible to determine the source of the file without using reflection.
return new ReflectionClass($migration)->getFileName();

Considering that the reference to the executable class is located next to the object at the moment of calling the event, it would be more logical to pass the path to the file as a parameter.

This will improve the mechanism for interacting with migrations, allowing you to perform some action when a particular migration is triggered.

@taylorotwell
Copy link
Member

Thanks for your pull request to Laravel!

Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include.

If applicable, please consider releasing your code as a package so that the community can still take advantage of your contributions!

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

Successfully merging this pull request may close these issues.

2 participants