id(); $table->integer('parent_id')->index()->nullable(); $table->string('name')->index()->nullable(); $table->string('code')->unique()->nullable()->comment('机器编码'); $table->integer('station_type_id')->index(); $table->integer('sequence')->index()->nullable(); $table->timestamps(); }); $db1 = DB::selectOne(DB::raw("SELECT * FROM station_types where name = ?"),["料箱出货口"]); $db2 = DB::selectOne(DB::raw("SELECT * FROM station_types where name = ?"),["料箱监视器01"]); if ($db1 && $db2){ DB::insert(DB::raw("INSERT INTO stations(name,code,station_type_id,parent_id,sequence) VALUES (?,?,?,?,?)"),[ 'U型线入货口01','BIN-OUT1',$db1->id,$db2->id,1, ]); } } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('stations'); } }