tables as $name) { if (! Schema::hasColumn($name, 'uuid')) { Schema::table($name, function (Blueprint $table) use ($name) { $table->uuid('uuid')->after('id')->nullable(); $table->index($name === 'accounts' ? ['uuid'] : ['account_id', 'uuid']); }); } } } /** * Reverse the migrations. * * @return void */ public function down() { foreach ($this->tables as $name) { if (Schema::hasColumn($name, 'uuid')) { Schema::table($name, function (Blueprint $table) use ($name) { try { $table->dropIndex($name === 'accounts' ? ['uuid'] : ['account_id', 'uuid']); $table->dropColumn('uuid'); } catch (\Exception $e) { // } }); } } } }