Is there any tool or programming technique to capture the output from Yii2 migrations to up/down SQL scripts, that is, print the migration corresponding raw SQL before finally running php yii migrate
?
For example, in Laravel you can add a flag --pretend
to output the queries to the terminal, like in php artisan migrate --pretend
. Is there anything similar in Yii Framework?
2
Answers
As @Bizley said when commenting the question, there is not a native way of doing it for Yii2 until the moment this question was answered.
For my case I just tracked my MySQL DB log and picked the queries I was looking for, since I had to set the current DB into a new one through migrations.
Just install Bizley’s migration package and try
php yii migration/sql m220914_000000_create_clients_table
for example, and the corresponding SQL statements can be extracted, like: