From 4d18c1bf8340c017540eafdd4ef2e017e583faed Mon Sep 17 00:00:00 2001 From: James Cole Date: Mon, 29 Mar 2021 18:53:31 +0200 Subject: [PATCH] Add if statement for DB migration issue. --- .../2021_03_12_061213_changes_for_v550b2.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/database/migrations/2021_03_12_061213_changes_for_v550b2.php b/database/migrations/2021_03_12_061213_changes_for_v550b2.php index 2de58e249b..a894a00324 100644 --- a/database/migrations/2021_03_12_061213_changes_for_v550b2.php +++ b/database/migrations/2021_03_12_061213_changes_for_v550b2.php @@ -42,7 +42,9 @@ class ChangesForV550b2 extends Migration 'recurrences_transactions', function (Blueprint $table) { $table->dropForeign('type_foreign'); - $table->dropColumn('transaction_type_id'); + if (Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) { + $table->dropColumn('transaction_type_id'); + } } ); @@ -58,8 +60,10 @@ class ChangesForV550b2 extends Migration // expand recurrence transaction table Schema::table( 'recurrences_transactions', function (Blueprint $table) { - $table->integer('transaction_type_id', false, true)->nullable()->after('transaction_currency_id'); - $table->foreign('transaction_type_id', 'type_foreign')->references('id')->on('transaction_types')->onDelete('set null'); + if (!Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) { + $table->integer('transaction_type_id', false, true)->nullable()->after('transaction_currency_id'); + $table->foreign('transaction_type_id', 'type_foreign')->references('id')->on('transaction_types')->onDelete('set null'); + } } ); }