LoginSignup
0
0

More than 1 year has passed since last update.

DBのカラム削除方法 Laravel

Last updated at Posted at 2021-06-05

使わないカラム名があったので消した。

消し方
まずマイグレーションを作る

$php artisan make:migration drop_column_テーブル名_column --table=テーブル名  

出来上がったマイグレーションに消したいカラム名を記載

   public function up()
   {
        Schema::table('posts', function (Blueprint $table) {
            //postsテーブルのカラム削除
            $table->dropColumn('カラム名');
        });
    }

マイグレーション実行

$php artisan migrate    

これで消せた!

0
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
0
0