From da88e02be095bbb96a04880463c87c97a509d4d0 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 28 Dec 2024 07:47:32 +0100 Subject: [PATCH] Catch exception. --- .../migrations/2024_11_30_075826_multi_piggy.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/database/migrations/2024_11_30_075826_multi_piggy.php b/database/migrations/2024_11_30_075826_multi_piggy.php index 09faaebcea..f32628e86f 100644 --- a/database/migrations/2024_11_30_075826_multi_piggy.php +++ b/database/migrations/2024_11_30_075826_multi_piggy.php @@ -13,14 +13,14 @@ return new class () extends Migration { public function up(): void { // make account_id nullable and the relation also nullable. - Schema::table('piggy_banks', static function (Blueprint $table): void { - // 1. drop index - try { + try { + Schema::table('piggy_banks', static function (Blueprint $table): void { + // 1. drop index $table->dropForeign('piggy_banks_account_id_foreign'); - } catch(RuntimeException $e) { - // do nothing. - } - }); + }); + } catch (RuntimeException $e) { + \Illuminate\Support\Facades\Log::error('Could not drop foreign key "piggy_banks_account_id_foreign". Probably not an issue.'); + } Schema::table('piggy_banks', static function (Blueprint $table): void { // 2. make column nullable. $table->unsignedInteger('account_id')->nullable()->change();