Add if statement for DB migration issue.

This commit is contained in:
James Cole 2021-03-29 18:53:31 +02:00
parent 22b376da71
commit 4d18c1bf83
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D

View File

@ -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');
}
}
);
}