Catch exception.

This commit is contained in:
James Cole
2024-12-28 07:47:32 +01:00
parent 0d56b7d251
commit da88e02be0

View File

@@ -13,14 +13,14 @@ return new class () extends Migration {
public function up(): void public function up(): void
{ {
// make account_id nullable and the relation also nullable. // make account_id nullable and the relation also nullable.
Schema::table('piggy_banks', static function (Blueprint $table): void { try {
// 1. drop index Schema::table('piggy_banks', static function (Blueprint $table): void {
try { // 1. drop index
$table->dropForeign('piggy_banks_account_id_foreign'); $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 { Schema::table('piggy_banks', static function (Blueprint $table): void {
// 2. make column nullable. // 2. make column nullable.
$table->unsignedInteger('account_id')->nullable()->change(); $table->unsignedInteger('account_id')->nullable()->change();