Closed TheFox closed 2 years ago
What is the namespace of the M221006094347Mailer class?
@bizley namespace modules\dsr_setup\migrations;
Does it work when you add to the migrate config 'migrationPath' => null
?
That does not make any difference.
I'm not sure what does module/enable
do? Does the migration work if you run it using yii migrate
?
'controllerMap' => [
// Application migrations:
'migrate' => [
'class' => yii\console\controllers\MigrateController::class,
'migrationPath' => null,
'migrationNamespaces' => ['modules\\dsr_setup\\migrations'],
],
// Yii migrations:
'yii-migrate' => [
'class' => yii\console\controllers\MigrateController::class,
'migrationPath' => [
'@yii/web/migrations',
// Note: update component's configuration before uncomment next migrations
// '@yii/rbac/migrations',
// '@yii/caching/migrations',
// '@yii/i18n/migrations',
// '@yii/log/migrations',
]
],
]
yii migrate/create modules\\dsr_setup\\migrations\\Mailer
is invalid command, call something like yii migrate/create create_mailer_table
or yii migrate/create modules\\dsr_setup\\migrations\\createMailerTable
Seems like module/enable
is not an original Yii 2 command. I guess this comes with the application (HumHub) I am using Yii 2 with. When I use yii migrate
it's working.
@WinterSilence
yii migrate/create modules\dsr_setup\migrations\Mailer is invalid command
Why is it an invalid command? It worked for me to create the class file.
If so I'm afraid you must take it to the HumHub for help. I'm closing this, please let me know if I can help with anything regarding Yii itself.
@TheFox command migrate
use special syntax, see guide for more info. You must add alias for namespace modules
: Yii::setAlias('@modules', '@app/modules')
in bootstrap class of module because file path generate as https://github.com/yiisoft/yii2/blob/0b4741ea6aa2fa58866c4eb65ef17c0b8d03323a/framework/console/controllers/BaseMigrateController.php#L741
@bizley Ok I see. Thank you for your help.
@WinterSilence There is an alias for that. When I use a namespace in a module the migration Class Name begins with an capital letter M.
For example, when I am using yii migrate/create modules\\dsr_setup\\migrations\\makeSomeChanges
it creates a class named M221006144332MakeSomeChanges
. The format is a little bit different to yii migrate/create makeSomeChanges
. It creates a m221006_145135_makeSomeChanges
class.
@TheFox as I'm already told, you can use syntax like as yii migrate/create modules\\dsr_setup\\migrations\\createMailerTable
. Look PHPDoc to actionCreate
https://github.com/yiisoft/yii2/blob/0b4741ea6aa2fa58866c4eb65ef17c0b8d03323a/framework/console/controllers/BaseMigrateController.php#L619
What steps will reproduce the problem?
I created a simple Module under
modules\dsr_setup
namespace. I also created a Migration under that modules namespace for migrations, usingyii migrate/create modules\\dsr_setup\\migrations\\Mailer
.I mapped the namespace in the Controller Map.
When I want to enable the module using
yii module/enable dsr-setup
the Migrations fail.What is the expected result?
I expect that the migrations are working while enabling the module.
What do you get instead?
Error Message
Additional info