diff --git a/framework/CHANGELOG.md b/framework/CHANGELOG.md index e3830dd..8dd54be 100644 --- a/framework/CHANGELOG.md +++ b/framework/CHANGELOG.md @@ -43,6 +43,7 @@ Yii Framework 2 Change Log - Enh #9137: Added `Access-Control-Allow-Method` header for the OPTIONS request (developeruz) - Enh #9253: Allow `variations` to be a string for `yii\filters\PageCache` and `yii\widgets\FragmentCache` (schojniak, developeruz) - Enh #12623: Added `yii\helpers\StringHelper::matchWildcard()` replacing usage of `fnmatch()`, which may be unreliable (klimov-paul) +- Enh #13919: Added option to add comment for created table to migration console command (mixartemev, developeruz) - Enh #14043: Added `yii\helpers\IpHelper` (silverfire, cebe) - Enh #14355: Added ability to pass an empty array as a parameter in console command (developeruz) - Enh #14568: Refactored migration templates to use `safeUp()` and `safeDown()` methods (Kolyunya) diff --git a/framework/console/controllers/MigrateController.php b/framework/console/controllers/MigrateController.php index f411a07..de511ed 100644 --- a/framework/console/controllers/MigrateController.php +++ b/framework/console/controllers/MigrateController.php @@ -132,6 +132,11 @@ class MigrateController extends BaseMigrateController * for creating the object. */ public $db = 'db'; + /** + * @var string the comment for the table being created. + * @since 2.0.14 + */ + public $comment = ''; /** @@ -143,7 +148,7 @@ class MigrateController extends BaseMigrateController parent::options($actionID), ['migrationTable', 'db'], // global for all actions $actionID === 'create' - ? ['templateFile', 'fields', 'useTablePrefix'] + ? ['templateFile', 'fields', 'useTablePrefix', 'comment'] : [] ); } @@ -155,6 +160,7 @@ class MigrateController extends BaseMigrateController public function optionAliases() { return array_merge(parent::optionAliases(), [ + 'c' => 'comment', 'f' => 'fields', 'p' => 'migrationPath', 't' => 'migrationTable', @@ -437,6 +443,7 @@ class MigrateController extends BaseMigrateController 'table' => $this->generateTableName($table), 'fields' => $fields, 'foreignKeys' => $foreignKeys, + 'tableComment' => $this->comment, ])); } diff --git a/framework/views/_addComments.php b/framework/views/_addComments.php new file mode 100644 index 0000000..fe59921 --- /dev/null +++ b/framework/views/_addComments.php @@ -0,0 +1,7 @@ + $this->addCommentOnTable('', ''); diff --git a/framework/views/createTableMigration.php b/framework/views/createTableMigration.php index 6701bdd..82f89f7 100644 --- a/framework/views/createTableMigration.php +++ b/framework/views/createTableMigration.php @@ -7,6 +7,7 @@ /* @var $className string the new migration class name without namespace */ /* @var $namespace string the new migration class namespace */ /* @var $table string the name table */ +/* @var $tableComment string the comment table */ /* @var $fields array the fields */ /* @var $foreignKeys array the foreign keys */ @@ -37,6 +38,13 @@ class extends Migration 'foreignKeys' => $foreignKeys, ]) ?> +render('_addComments', [ + 'table' => $table, + 'tableComment' => $tableComment, + ]); +} +?> } /**