megapixel23
megapixel23

Reputation: 855

Add comment to SQL table

How can I add comment for specific SQL-table in Yii2 migration?

SQL code:

ALTER TABLE my_table COMMENT 'Hello World'

I wand to do in within a migration in ORM way

Upvotes: 3

Views: 1282

Answers (2)

Yasar Arafath
Yasar Arafath

Reputation: 625

In yii2 format

  • addCommentOnColumn($table, $column, $comment)
  • dropCommentFromColumn($table, $column)
  • addCommentOnTable($table, $comment)
  • dropCommentFromTable($table)

Example: In migration file

$this->addCommentOnColumn('user','role_id','Relation table of role');

Upvotes: 3

arogachev
arogachev

Reputation: 33538

Currently there is no such functionality in Yii 2 migrations.

You have to write it in plain SQL via execute() method:

$this->execute("ALTER TABLE my_table COMMENT 'Hello World'");

Upvotes: 1

Related Questions