LoginSignup
1
4

More than 5 years have passed since last update.

CakePHP3マイグレーション時にテーブルコメント、カラムコメントを追加する

Posted at

以下の書き方でいける

$table = $this->table('table_name', ['comment', 'テーブルの説明']);
$table->addColumn('name', 'string', [
    'default' => '',
    'limit' => 255,
    'null' => false,
    'comment' => 'カラムの説明'
]);

ドキュメントの運用とか面倒なので、このようにテーブル、カラムコメントで運用してくとやりやすそう。

ちなみに、SQLでコメントを確認すると時は以下のやり方がある。

> show table status like 'table_name';
show full columns from table_name;

(参考) https://qiita.com/snaka/items/28c636214099f3b99c18

もしくは、これ。

> SHOW CREATE TABLE table_name;
1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4