migrate操作一覧

基本の流れ

【ターミナル】

php artisan make:migration add_column_カラム名_to_テーブル名_table --table=テーブル名

マイグレーションファイル】

  public function up()
    {

public function down()
    {

に希望の操作を記述

【ターミナル】

php artisan migrate

 

○既存のテーブルにカラムを追加

例)

up

$table->foreignId('user_id')->after('image');

down

$table->dropColumn('user_id');