Skip to content

pass options to migration events#54151

Merged
taylorotwell merged 2 commits intolaravel:11.xfrom
willpower232:pass-options-to-migration-events
Jan 13, 2025
Merged

pass options to migration events#54151
taylorotwell merged 2 commits intolaravel:11.xfrom
willpower232:pass-options-to-migration-events

Conversation

@willpower232
Copy link
Copy Markdown
Contributor

As discussed in #48801

You can run php artisan migrate --pretend which outputs the raw SQL from the migrations rather than executing them.

The problem is this extra context is not added to the events issued

This means if you have database-altering code relying on these events, they could throw exceptions or cause errors in production.

I passed through the whole $options array to make it slightly more future proof in case there are other options added in the future.

I had a few issues writing tests for it which is why testMigrationEventsContainTheOptionsAndPretendTrue is a bit shorter but I also figure that the rollback event is tested in testMigrationEventsContainTheOptionsAndPretendFalse so doesn't necessarily need a duplicated test.

I would also be interested in changing the base event for php 8 constructor property promotion which I can see being used in a few other classes in the framework but I didn't want to just jump into that bit without confirming it was okay.

@taylorotwell taylorotwell merged commit 2096aaf into laravel:11.x Jan 13, 2025
@willpower232
Copy link
Copy Markdown
Contributor Author

Thanks!

@willpower232 willpower232 deleted the pass-options-to-migration-events branch January 13, 2025 17:20
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