glushkovds / phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel
MIT License
147 stars 26 forks source link

Add support for Laravel migration pretend mode #16

Closed lebedevsergey closed 2 years ago

lebedevsergey commented 2 years ago

In Laravel there is migration pretend mode, when migration is not really applied but shows SQL that will be applied. However this mode is not supported by phpclickhouse-laravel. This can cause issues when user launches DB-migrations with artisan migrate --pretend and expects that migrations will be applied but only shown. So I added the support for pretend mode.

glushkovds commented 2 years ago

Hi Sergey! Using debug_backtrace is not the best choice. Maybe exist more direct way to detect pretend mode? Like detect option from cli params or use laravel environment?

glushkovds commented 2 years ago

I tried to find another solution but didn't find.
I modified your PR a little. Check out the latest tag, v1.15.4.

Thanks for your contribution.

lebedevsergey commented 2 years ago

Hello! Thank you for adopting my PR! I agree that it is a bit too low level approach to use debug_backtrace for detecting pretend mode which could lead to incompatibility with future Laravel version. Though with the current architecture (when Clickhouse migrations use static write method defined in Migration class) it is difficult to find other method to check for pretend mode.