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

[8.x] Resolve Blueprint class out of the container #40307

Merged
merged 1 commit into from
Jan 10, 2022

Conversation

imanghafoori1
Copy link
Contributor

Currently, it is almost impossible to swap the Blueprint $table implementation for migrations with a fake one from within a "package space".
Because the Schema facade returns a new object each time from the getFacadeAccessor method (hence there is no way of mocking or hot swapping) and non of the other objects are resolved out of the container. (Connection objects or Builder objects)
There is also no change of using the resolver property on the Builder class from a package space because if you set it before the migration starts it will be thrown away after the Schema is called in the migration.

Currently "illuminate/database" depends on "illuminate/container" so we can use the Container class directly. (if not wrong)
This way it is possible to swap the Blueprint class upon the registration phase.

Currently, it is almost impossible to swap the `Blueprint $table` implementation for migrations with a fake one from within a "package space".
Because the `Schema` facade returns a new object each time from the `getFacadeAccessor` method (hence there is no way of mocking or hot swapping) and non of the other objects are resolved out of the container. (Connection objects or Builder objects)
There is also no change of using the `resolver` property on the `Builder` class from a package space because if you set it before the migration starts it will be thrown away after the `Schema` is called in the migration.

Currently "illuminate/database" depends on "illuminate/container" so we can use the Container class directly.
This way it is possible to swap the Blueprint class upon the `registration phase`.
@taylorotwell
Copy link
Member

Why do you want to write a custom Blueprint?

@imanghafoori1
Copy link
Contributor Author

imanghafoori1 commented Jan 8, 2022

This is part of the migrator UI package, we need to have a spy blueprint to see what is going to be done in migrations without actually performing them. Currently, the package is reading the migration code by regex, which is crappy.

https://github.com/rezaamini-ir/migrator

Custom Blueprint can also be used to avoid certain queries in some environments, like avoiding the creation of indexes in test mode.

@taylorotwell taylorotwell merged commit 4b06bb4 into laravel:8.x Jan 10, 2022
@imanghafoori1 imanghafoori1 deleted the patch-3 branch January 13, 2022 16:09
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