*/ use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class DropEmailsOnCustomersDeletion extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('emails', function (Blueprint $table) { // Ensure emails entries are dropped when the related customer entry is deleted. $table ->foreign('customer_id') ->references('id') ->on('customers') ->onDelete('cascade'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('emails', function (Blueprint $table) { // Drop the foreign key constraint. $table->dropForeign(['customer_id']); }); } }