Answer the question
In order to leave comments, you need to log in
How to perform all migrations from modules in Yii2 with one command?
Hello!
I have a middle-aged project in which a huge number of migrations have already accumulated. I would like to scatter them among the application modules in order to restore at least some order, but:
Answer the question
In order to leave comments, you need to log in
All in all, https://github.com/deesoft/yii2-console turned out to be the easiest solution. I use it.
1 - you can make a script file with paths already written
2 - theoretically you can make a file parser that finds the desired directory and feeds the path to the standard tool
Yii migrate already finds all the migrations that were not applied. And applies them in ascending order by timeStamp.
For individual modules, you can roll like this
interactive: Boolean - boolean (true by default). Specifies whether the migration should be performed interactively. If this value is true, then the user will be prompted before the command performs certain actions. You can set this value to false if the command is running in the background.
In the config of the console application, write controllerMap for the migrate controller of the path to the migrations in the modules.
Here is an example:
'controllerMap' => [
'migrate' => [
'class' => 'yii\console\controllers\MigrateController',
'migrationNamespaces' => [
'app\modules\courses\migrations'
],
// ...
],
],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question