Laravel MongoDB: mongodbを使用時にmigration file で table を定義する

環境

Laravel@8.79.0

Jenssegers/mongodb@3.8.4

 

migration をしなくても ORM から query することで DB に table を作成することができるが、 migration file を作って DB table を定義したい場合、

php artisan make:migration create_MONGO_TABLE_MODEL_table

 

public function up() {

  Schema::connection('mongodb')->create('MONGO_TABLE_NAME', function(Blueprint $table)) {

  //

  }

}

 

connection('mongodb') で接続先DBを指定