diff --git a/CHANGELOG-v3.md b/CHANGELOG-v3.md index abb21ffadeb..93c491ab927 100644 --- a/CHANGELOG-v3.md +++ b/CHANGELOG-v3.md @@ -10,6 +10,7 @@ - Fixed a bug where new user groups weren’t getting set on user accounts in time for activation email templates to reference them. ([#6225](https://github.com/craftcms/cms/issues/6225)) - Fixed an error that occurred when adding multiple tags that began with the word “not”. - Fixed a bug where it was possible to create two tags with the same title, but different casing. ([#6229](https://github.com/craftcms/cms/issues/6229)) +- Fixed a bug where the `migrate/all` command would create a `migrations/` folder for no good reason. ([#6220](https://github.com/craftcms/cms/issues/6220)) ## 3.4.24 - 2020-06-16 diff --git a/src/console/controllers/MigrateController.php b/src/console/controllers/MigrateController.php index 78358049204..1850298b904 100644 --- a/src/console/controllers/MigrateController.php +++ b/src/console/controllers/MigrateController.php @@ -107,13 +107,12 @@ public function options($actionID) ArrayHelper::removeValue($options, 'migrationNamespaces'); ArrayHelper::removeValue($options, 'compact'); - // Global options - $options[] = 'type'; - $options[] = 'plugin'; - if ($actionID === 'all') { $options[] = 'noBackup'; $options[] = 'noContent'; + } else { + $options[] = 'type'; + $options[] = 'plugin'; } return $options; @@ -137,33 +136,35 @@ public function optionAliases() */ public function beforeAction($action) { - // Validate $type - if ($this->plugin) { - $this->type = MigrationManager::TYPE_PLUGIN; - } - if (!in_array($this->type, [MigrationManager::TYPE_APP, MigrationManager::TYPE_PLUGIN, MigrationManager::TYPE_CONTENT], true)) { - throw new Exception('Invalid migration type: ' . $this->type); - } - if ($this->type === MigrationManager::TYPE_PLUGIN) { - // Make sure $this->plugin in set to a valid plugin handle - if (empty($this->plugin)) { - $this->stderr('You must specify the plugin handle using the --plugin option.' . PHP_EOL, Console::FG_RED); - return false; + if ($action->id !== 'all') { + // Validate $type + if ($this->plugin) { + $this->type = MigrationManager::TYPE_PLUGIN; } - $pluginsService = Craft::$app->getPlugins(); - if (($plugin = $pluginsService->getPlugin($this->plugin)) === null) { - try { - $plugin = $pluginsService->createPlugin($this->plugin); - } catch (InvalidPluginException $e) { - $this->stderr('Invalid plugin handle: ' . $this->plugin . PHP_EOL, Console::FG_RED); + if (!in_array($this->type, [MigrationManager::TYPE_APP, MigrationManager::TYPE_PLUGIN, MigrationManager::TYPE_CONTENT], true)) { + throw new Exception('Invalid migration type: ' . $this->type); + } + if ($this->type === MigrationManager::TYPE_PLUGIN) { + // Make sure $this->plugin in set to a valid plugin handle + if (empty($this->plugin)) { + $this->stderr('You must specify the plugin handle using the --plugin option.' . PHP_EOL, Console::FG_RED); return false; } + $pluginsService = Craft::$app->getPlugins(); + if (($plugin = $pluginsService->getPlugin($this->plugin)) === null) { + try { + $plugin = $pluginsService->createPlugin($this->plugin); + } catch (InvalidPluginException $e) { + $this->stderr('Invalid plugin handle: ' . $this->plugin . PHP_EOL, Console::FG_RED); + return false; + } + } + $this->plugin = $plugin; } - $this->plugin = $plugin; - } - $this->migrationPath = $this->getMigrator()->migrationPath; - FileHelper::createDirectory($this->migrationPath); + $this->migrationPath = $this->getMigrator()->migrationPath; + FileHelper::createDirectory($this->migrationPath); + } if (!parent::beforeAction($action)) { return false;