1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

laravel マイグレーションでテーブルコメントをつける

Posted at

概要

  • マイグレーションでテーブルにコメントを付ける方法をまとめる。

ご注意

  • 本方法でテーブルにコメントがつけられるのは現在MySQLとPostgresのみである。

方法

  • マイグレーションファイルに下記のように記載する。

    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('テーブル名', function (Blueprint $table) {
            $table->comment('テーブルのコメント');
        });
    }
    
  • マイグレーションを実行する。

  • ちなみに下記SQLを実行した結果のcommentを見ることにより、テーブルのコメントが入っていることを確認できる。

    show table status;
    
1
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?