Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Catch DB errors
James Cole79a4eec96e76
diff --git a/database/migrations/2016_08_25_091522_changes_for_3101.php b/database/migrations/2016_08_25_091522_changes_for_3101.phpindex 611145cb5c..b56dd89926 100644--- a/database/migrations/2016_08_25_091522_changes_for_3101.php+++ b/database/migrations/2016_08_25_091522_changes_for_3101.php@@ -22,7 +22,6 @@declare(strict_types=1);use Illuminate\Database\Migrations\Migration;-use Illuminate\Database\Schema\Blueprint;/*** Class ChangesFor3101.@@ -36,14 +35,6 @@ class ChangesFor3101 extends Migration*/public function down(): void{- Schema::table(- 'import_jobs',- static function (Blueprint $table) {- if (Schema::hasColumn('import_jobs', 'extended_status')) {- $table->dropColumn('extended_status');- }- }- );}/**@@ -53,13 +44,5 @@ class ChangesFor3101 extends Migration*/public function up(): void{- Schema::table(- 'import_jobs',- static function (Blueprint $table) {- if (!Schema::hasColumn('import_jobs', 'extended_status')) {- $table->text('extended_status')->nullable();- }- }- );}}diff --git a/database/migrations/2016_09_12_121359_fix_nullables.php b/database/migrations/2016_09_12_121359_fix_nullables.phpindex c9bf391dff..0effd41a8b 100644--- a/database/migrations/2016_09_12_121359_fix_nullables.php+++ b/database/migrations/2016_09_12_121359_fix_nullables.php@@ -22,6 +22,7 @@declare(strict_types=1);use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;/**@@ -45,18 +46,28 @@ class FixNullables extends Migration*/public function up(): void{- Schema::table(- 'rule_groups',- static function (Blueprint $table) {- $table->text('description')->nullable()->change();- }- );+ try {+ Schema::table(+ 'rule_groups',+ static function (Blueprint $table) {+ $table->text('description')->nullable()->change();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not update table: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }- Schema::table(- 'rules',- static function (Blueprint $table) {- $table->text('description')->nullable()->change();- }- );+ try {+ Schema::table(+ 'rules',+ static function (Blueprint $table) {+ $table->text('description')->nullable()->change();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2016_10_09_150037_expand_transactions_table.php b/database/migrations/2016_10_09_150037_expand_transactions_table.phpindex 85da51be47..e2d6188ebd 100644--- a/database/migrations/2016_10_09_150037_expand_transactions_table.php+++ b/database/migrations/2016_10_09_150037_expand_transactions_table.php@@ -21,7 +21,9 @@*/declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;/**@@ -36,12 +38,17 @@ class ExpandTransactionsTable extends Migration*/public function down(): void{- Schema::table(- 'transactions',- static function (Blueprint $table) {- $table->dropColumn('identifier');- }- );+ try {+ Schema::table(+ 'transactions',+ static function (Blueprint $table) {+ $table->dropColumn('identifier');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not drop column "extended_status": %s', $e->getMessage()));+ Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -51,11 +58,16 @@ class ExpandTransactionsTable extends Migration*/public function up(): void{- Schema::table(- 'transactions',- static function (Blueprint $table) {- $table->smallInteger('identifier', false, true)->default(0);- }- );+ try {+ Schema::table(+ 'transactions',+ static function (Blueprint $table) {+ $table->smallInteger('identifier', false, true)->default(0);+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2016_11_24_210552_changes_for_v420.php b/database/migrations/2016_11_24_210552_changes_for_v420.phpindex a6884f164d..b6de4904b7 100644--- a/database/migrations/2016_11_24_210552_changes_for_v420.php+++ b/database/migrations/2016_11_24_210552_changes_for_v420.php@@ -22,6 +22,7 @@declare(strict_types=1);use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;/**@@ -36,12 +37,17 @@ class ChangesForV420 extends Migration*/public function down(): void{- Schema::table(- 'journal_meta',- static function (Blueprint $table) {- $table->dropSoftDeletes();- }- );+ try {+ Schema::table(+ 'journal_meta',+ static function (Blueprint $table) {+ $table->dropSoftDeletes();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -51,11 +57,16 @@ class ChangesForV420 extends Migration*/public function up(): void{- Schema::table(- 'journal_meta',- static function (Blueprint $table) {- $table->softDeletes();- }- );+ try {+ Schema::table(+ 'journal_meta',+ static function (Blueprint $table) {+ $table->softDeletes();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2016_12_28_203205_changes_for_v431.php b/database/migrations/2016_12_28_203205_changes_for_v431.phpindex 66b25ffb80..bdfd992bde 100644--- a/database/migrations/2016_12_28_203205_changes_for_v431.php+++ b/database/migrations/2016_12_28_203205_changes_for_v431.php@@ -21,7 +21,9 @@*/declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;/**@@ -37,41 +39,66 @@ class ChangesForV431 extends Migrationpublic function down(): void{// reinstate "repeats" and "repeat_freq".- Schema::table(- 'budget_limits',- static function (Blueprint $table) {- $table->string('repeat_freq', 30)->nullable();- }- );- Schema::table(- 'budget_limits',- static function (Blueprint $table) {- $table->boolean('repeats')->default(0);- }- );+ try {+ Schema::table(+ 'budget_limits',+ static function (Blueprint $table) {+ $table->string('repeat_freq', 30)->nullable();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }+ try {+ Schema::table(+ 'budget_limits',+ static function (Blueprint $table) {+ $table->boolean('repeats')->default(0);+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }// change field "start_date" to "startdate"- Schema::table(- 'budget_limits',- static function (Blueprint $table) {- $table->renameColumn('start_date', 'startdate');- }- );+ try {+ Schema::table(+ 'budget_limits',+ static function (Blueprint $table) {+ $table->renameColumn('start_date', 'startdate');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }// remove date field "end_date"- Schema::table(- 'budget_limits',- static function (Blueprint $table) {- $table->dropColumn('end_date');- }- );+ try {+ Schema::table(+ 'budget_limits',+ static function (Blueprint $table) {+ $table->dropColumn('end_date');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }// remove decimal places- Schema::table(- 'transaction_currencies',- static function (Blueprint $table) {- $table->dropColumn('decimal_places');- }- );+ try {+ Schema::table(+ 'transaction_currencies',+ static function (Blueprint $table) {+ $table->dropColumn('decimal_places');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -83,41 +110,66 @@ class ChangesForV431 extends Migrationpublic function up(): void{// add decimal places to "transaction currencies".- Schema::table(- 'transaction_currencies',- static function (Blueprint $table) {- $table->smallInteger('decimal_places', false, true)->default(2);- }- );+ try {+ Schema::table(+ 'transaction_currencies',+ static function (Blueprint $table) {+ $table->smallInteger('decimal_places', false, true)->default(2);+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }// change field "startdate" to "start_date"- Schema::table(- 'budget_limits',- static function (Blueprint $table) {- $table->renameColumn('startdate', 'start_date');- }- );+ try {+ Schema::table(+ 'budget_limits',+ static function (Blueprint $table) {+ $table->renameColumn('startdate', 'start_date');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }// add date field "end_date" after "start_date"- Schema::table(- 'budget_limits',- static function (Blueprint $table) {- $table->date('end_date')->nullable()->after('start_date');- }- );+ try {+ Schema::table(+ 'budget_limits',+ static function (Blueprint $table) {+ $table->date('end_date')->nullable()->after('start_date');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }// drop "repeats" and "repeat_freq".- Schema::table(- 'budget_limits',- static function (Blueprint $table) {- $table->dropColumn('repeats');- }- );- Schema::table(- 'budget_limits',- static function (Blueprint $table) {- $table->dropColumn('repeat_freq');- }- );+ try {+ Schema::table(+ 'budget_limits',+ static function (Blueprint $table) {+ $table->dropColumn('repeats');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }+ try {+ Schema::table(+ 'budget_limits',+ static function (Blueprint $table) {+ $table->dropColumn('repeat_freq');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2017_04_13_163623_changes_for_v440.php b/database/migrations/2017_04_13_163623_changes_for_v440.phpindex e8adb504f9..330bdf3431 100644--- a/database/migrations/2017_04_13_163623_changes_for_v440.php+++ b/database/migrations/2017_04_13_163623_changes_for_v440.php@@ -21,6 +21,7 @@*/declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;@@ -37,22 +38,24 @@ class ChangesForV440 extends Migration*/public function down(): void{- if (Schema::hasTable('currency_exchange_rates')) {- Schema::dropIfExists('currency_exchange_rates');- }-- Schema::table(- 'transactions',- static function (Blueprint $table) {- if (Schema::hasColumn('transactions', 'transaction_currency_id')) {- // cannot drop foreign keys in SQLite:- if ('sqlite' !== config('database.default')) {- $table->dropForeign('transactions_transaction_currency_id_foreign');+ Schema::dropIfExists('currency_exchange_rates');+ try {+ Schema::table(+ 'transactions',+ static function (Blueprint $table) {+ if (Schema::hasColumn('transactions', 'transaction_currency_id')) {+ // cannot drop foreign keys in SQLite:+ if ('sqlite' !== config('database.default')) {+ $table->dropForeign('transactions_transaction_currency_id_foreign');+ }+ $table->dropColumn('transaction_currency_id');}- $table->dropColumn('transaction_currency_id');}- }- );+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -88,14 +91,19 @@ class ChangesForV440 extends Migration}}- Schema::table(- 'transactions',- static function (Blueprint $table) {- if (!Schema::hasColumn('transactions', 'transaction_currency_id')) {- $table->integer('transaction_currency_id', false, true)->after('description')->nullable();- $table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');+ try {+ Schema::table(+ 'transactions',+ static function (Blueprint $table) {+ if (!Schema::hasColumn('transactions', 'transaction_currency_id')) {+ $table->integer('transaction_currency_id', false, true)->after('description')->nullable();+ $table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');+ }}- }- );+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2017_06_02_105232_changes_for_v450.php b/database/migrations/2017_06_02_105232_changes_for_v450.phpindex 706a75fe39..c632ec6aa3 100644--- a/database/migrations/2017_06_02_105232_changes_for_v450.php+++ b/database/migrations/2017_06_02_105232_changes_for_v450.php@@ -21,7 +21,9 @@*/declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;/**@@ -37,29 +39,44 @@ class ChangesForV450 extends Migrationpublic function down(): void{// split up for sqlite compatibility- Schema::table(- 'transactions',- static function (Blueprint $table) {- $table->dropColumn('foreign_amount');- }- );+ try {+ Schema::table(+ 'transactions',+ static function (Blueprint $table) {+ $table->dropColumn('foreign_amount');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }- Schema::table(- 'transactions',- static function (Blueprint $table) {- // cannot drop foreign keys in SQLite:- if ('sqlite' !== config('database.default')) {- $table->dropForeign('transactions_foreign_currency_id_foreign');+ try {+ Schema::table(+ 'transactions',+ static function (Blueprint $table) {+ // cannot drop foreign keys in SQLite:+ if ('sqlite' !== config('database.default')) {+ $table->dropForeign('transactions_foreign_currency_id_foreign');+ }}- }- );+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }- Schema::table(- 'transactions',- static function (Blueprint $table) {- $table->dropColumn('foreign_currency_id');- }- );+ try {+ Schema::table(+ 'transactions',+ static function (Blueprint $table) {+ $table->dropColumn('foreign_currency_id');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -70,20 +87,30 @@ class ChangesForV450 extends Migrationpublic function up(): void{// add "foreign_amount" to transactions- Schema::table(- 'transactions',- static function (Blueprint $table) {- $table->decimal('foreign_amount', 32, 12)->nullable()->after('amount');- }- );+ try {+ Schema::table(+ 'transactions',+ static function (Blueprint $table) {+ $table->decimal('foreign_amount', 32, 12)->nullable()->after('amount');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }// add foreign transaction currency id to transactions (is nullable):- Schema::table(- 'transactions',- static function (Blueprint $table) {- $table->integer('foreign_currency_id', false, true)->default(null)->after('foreign_amount')->nullable();- $table->foreign('foreign_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');- }- );+ try {+ Schema::table(+ 'transactions',+ static function (Blueprint $table) {+ $table->integer('foreign_currency_id', false, true)->default(null)->after('foreign_amount')->nullable();+ $table->foreign('foreign_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2017_11_04_170844_changes_for_v470a.php b/database/migrations/2017_11_04_170844_changes_for_v470a.phpindex dcc1ada526..7132ef40e2 100644--- a/database/migrations/2017_11_04_170844_changes_for_v470a.php+++ b/database/migrations/2017_11_04_170844_changes_for_v470a.php@@ -21,7 +21,9 @@*/declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;@@ -37,12 +39,17 @@ class ChangesForV470a extends Migration*/public function down(): void{- Schema::table(- 'transactions',- static function (Blueprint $table) {- $table->dropColumn('reconciled');- }- );+ try {+ Schema::table(+ 'transactions',+ static function (Blueprint $table) {+ $table->dropColumn('reconciled');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -52,11 +59,16 @@ class ChangesForV470a extends Migration*/public function up(): void{- Schema::table(- 'transactions',- static function (Blueprint $table) {- $table->boolean('reconciled')->after('deleted_at')->default(0);- }- );+ try {+ Schema::table(+ 'transactions',+ static function (Blueprint $table) {+ $table->boolean('reconciled')->after('deleted_at')->default(0);+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2018_03_19_141348_changes_for_v472.php b/database/migrations/2018_03_19_141348_changes_for_v472.phpindex 060d83cf4b..0c046f9914 100644--- a/database/migrations/2018_03_19_141348_changes_for_v472.php+++ b/database/migrations/2018_03_19_141348_changes_for_v472.php@@ -22,7 +22,9 @@declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;/**@@ -39,18 +41,29 @@ class ChangesForV472 extends Migration*/public function down(): void{- Schema::table(- 'attachments',- static function (Blueprint $table) {- $table->text('notes')->nullable();- }- );- Schema::table(- 'budgets',- static function (Blueprint $table) {- $table->dropColumn('order');- }- );+ try {+ Schema::table(+ 'attachments',+ static function (Blueprint $table) {+ $table->text('notes')->nullable();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }++ try {+ Schema::table(+ 'budgets',+ static function (Blueprint $table) {+ $table->dropColumn('order');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -61,18 +74,28 @@ class ChangesForV472 extends Migration*/public function up(): void{- Schema::table(- 'attachments',- static function (Blueprint $table) {- $table->dropColumn('notes');- }- );+ try {+ Schema::table(+ 'attachments',+ static function (Blueprint $table) {+ $table->dropColumn('notes');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }- Schema::table(- 'budgets',- static function (Blueprint $table) {- $table->mediumInteger('order', false, true)->default(0);- }- );+ try {+ Schema::table(+ 'budgets',+ static function (Blueprint $table) {+ $table->mediumInteger('order', false, true)->default(0);+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2018_04_07_210913_changes_for_v473.php b/database/migrations/2018_04_07_210913_changes_for_v473.phpindex 33e93911f8..53a4960338 100644--- a/database/migrations/2018_04_07_210913_changes_for_v473.php+++ b/database/migrations/2018_04_07_210913_changes_for_v473.php@@ -22,7 +22,9 @@declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;@@ -40,23 +42,34 @@ class ChangesForV473 extends Migration*/public function down(): void{- Schema::table(- 'bills',- static function (Blueprint $table) {- // cannot drop foreign keys in SQLite:- if ('sqlite' !== config('database.default')) {- $table->dropForeign('bills_transaction_currency_id_foreign');+ try {+ Schema::table(+ 'bills',+ static function (Blueprint $table) {+ // cannot drop foreign keys in SQLite:+ if ('sqlite' !== config('database.default')) {+ $table->dropForeign('bills_transaction_currency_id_foreign');+ }+ $table->dropColumn('transaction_currency_id');}- $table->dropColumn('transaction_currency_id');- }- );+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }- Schema::table(- 'rules',- static function (Blueprint $table) {- $table->dropColumn('strict');- }- );++ try {+ Schema::table(+ 'rules',+ static function (Blueprint $table) {+ $table->dropColumn('strict');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -67,18 +80,28 @@ class ChangesForV473 extends Migration*/public function up(): void{- Schema::table(- 'bills',- static function (Blueprint $table) {- $table->integer('transaction_currency_id', false, true)->nullable()->after('user_id');- $table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');- }- );- Schema::table(- 'rules',- static function (Blueprint $table) {- $table->boolean('strict')->default(true);- }- );+ try {+ Schema::table(+ 'bills',+ static function (Blueprint $table) {+ $table->integer('transaction_currency_id', false, true)->nullable()->after('user_id');+ $table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }+ try {+ Schema::table(+ 'rules',+ static function (Blueprint $table) {+ $table->boolean('strict')->default(true);+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2018_04_29_174524_changes_for_v474.php b/database/migrations/2018_04_29_174524_changes_for_v474.phpindex 132b86dc47..7e570e57a6 100644--- a/database/migrations/2018_04_29_174524_changes_for_v474.php+++ b/database/migrations/2018_04_29_174524_changes_for_v474.php@@ -23,7 +23,6 @@declare(strict_types=1);use Illuminate\Database\Migrations\Migration;-use Illuminate\Database\Schema\Blueprint;/*** Class ChangesForV474.@@ -34,57 +33,11 @@ class ChangesForV474 extends Migration{/*** Reverse the migrations.- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)** @return void*/public function down(): void{- // split up for sqlite compatibility.- Schema::table(- 'import_jobs',- static function (Blueprint $table) {- // cannot drop foreign keys in SQLite:- if ('sqlite' !== config('database.default')) {- $table->dropForeign('import_jobs_tag_id_foreign');- }- }- );-- Schema::table(- 'import_jobs',- static function (Blueprint $table) {- $table->dropColumn('provider');- }- );-- Schema::table(- 'import_jobs',- static function (Blueprint $table) {- $table->dropColumn('stage');- }- );-- Schema::table(- 'import_jobs',- static function (Blueprint $table) {- $table->dropColumn('transactions');- }- );-- Schema::table(- 'import_jobs',- static function (Blueprint $table) {- $table->dropColumn('errors');- }- );-- Schema::table(- 'import_jobs',- static function (Blueprint $table) {- $table->dropColumn('tag_id');- }- );}/**@@ -95,17 +48,5 @@ class ChangesForV474 extends Migration*/public function up(): void{- Schema::table(- 'import_jobs',- static function (Blueprint $table) {- $table->string('provider', 50)->after('file_type')->default('');- $table->string('stage', 50)->after('status')->default('');- $table->longText('transactions')->after('extended_status')->nullable();- $table->longText('errors')->after('transactions')->nullable();-- $table->integer('tag_id', false, true)->nullable()->after('user_id');- $table->foreign('tag_id')->references('id')->on('tags')->onDelete('set null');- }- );}}diff --git a/database/migrations/2018_06_08_200526_changes_for_v475.php b/database/migrations/2018_06_08_200526_changes_for_v475.phpindex 53d29b2ed7..0ecdd6bb0a 100644--- a/database/migrations/2018_06_08_200526_changes_for_v475.php+++ b/database/migrations/2018_06_08_200526_changes_for_v475.php@@ -85,93 +85,93 @@ class ChangesForV475 extends MigrationLog::error(sprintf('Could not create table "recurrences": %s', $e->getMessage()));Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');}-try {- Schema::create(- 'recurrences_transactions',- static function (Blueprint $table) {- $table->increments('id');- $table->timestamps();- $table->softDeletes();- $table->integer('recurrence_id', false, true);- $table->integer('transaction_currency_id', false, true);- $table->integer('foreign_currency_id', false, true)->nullable();- $table->integer('source_id', false, true);- $table->integer('destination_id', false, true);-- $table->decimal('amount', 32, 12);- $table->decimal('foreign_amount', 32, 12)->nullable();- $table->string('description', 1024);-- $table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');- $table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');- $table->foreign('foreign_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');- $table->foreign('source_id')->references('id')->on('accounts')->onDelete('cascade');- $table->foreign('destination_id')->references('id')->on('accounts')->onDelete('cascade');+ try {+ Schema::create(+ 'recurrences_transactions',+ static function (Blueprint $table) {+ $table->increments('id');+ $table->timestamps();+ $table->softDeletes();+ $table->integer('recurrence_id', false, true);+ $table->integer('transaction_currency_id', false, true);+ $table->integer('foreign_currency_id', false, true)->nullable();+ $table->integer('source_id', false, true);+ $table->integer('destination_id', false, true);++ $table->decimal('amount', 32, 12);+ $table->decimal('foreign_amount', 32, 12)->nullable();+ $table->string('description', 1024);++ $table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');+ $table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');+ $table->foreign('foreign_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');+ $table->foreign('source_id')->references('id')->on('accounts')->onDelete('cascade');+ $table->foreign('destination_id')->references('id')->on('accounts')->onDelete('cascade');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "recurrences_transactions": %s', $e->getMessage()));+ Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');}- );-} catch (QueryException $e) {- Log::error(sprintf('Could not create table "recurrences_transactions": %s', $e->getMessage()));- Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');-}-try {- Schema::create(- 'recurrences_repetitions',- static function (Blueprint $table) {- $table->increments('id');- $table->timestamps();- $table->softDeletes();- $table->integer('recurrence_id', false, true);- $table->string('repetition_type', 50);- $table->string('repetition_moment', 50);- $table->smallInteger('repetition_skip', false, true);- $table->smallInteger('weekend', false, true);-- $table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');+ try {+ Schema::create(+ 'recurrences_repetitions',+ static function (Blueprint $table) {+ $table->increments('id');+ $table->timestamps();+ $table->softDeletes();+ $table->integer('recurrence_id', false, true);+ $table->string('repetition_type', 50);+ $table->string('repetition_moment', 50);+ $table->smallInteger('repetition_skip', false, true);+ $table->smallInteger('weekend', false, true);++ $table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "recurrences_repetitions": %s', $e->getMessage()));+ Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');}- );-} catch (QueryException $e) {- Log::error(sprintf('Could not create table "recurrences_repetitions": %s', $e->getMessage()));- Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');-}-try {- Schema::create(- 'recurrences_meta',- static function (Blueprint $table) {- $table->increments('id');- $table->timestamps();- $table->softDeletes();- $table->integer('recurrence_id', false, true);+ try {+ Schema::create(+ 'recurrences_meta',+ static function (Blueprint $table) {+ $table->increments('id');+ $table->timestamps();+ $table->softDeletes();+ $table->integer('recurrence_id', false, true);- $table->string('name', 50);- $table->text('value');+ $table->string('name', 50);+ $table->text('value');- $table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');+ $table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "recurrences_meta": %s', $e->getMessage()));+ Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');}- );-} catch (QueryException $e) {- Log::error(sprintf('Could not create table "recurrences_meta": %s', $e->getMessage()));- Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');-}-try {- Schema::create(- 'rt_meta',- static function (Blueprint $table) {- $table->increments('id');- $table->timestamps();- $table->softDeletes();- $table->integer('rt_id', false, true);-- $table->string('name', 50);- $table->text('value');-- $table->foreign('rt_id')->references('id')->on('recurrences_transactions')->onDelete('cascade');+ try {+ Schema::create(+ 'rt_meta',+ static function (Blueprint $table) {+ $table->increments('id');+ $table->timestamps();+ $table->softDeletes();+ $table->integer('rt_id', false, true);++ $table->string('name', 50);+ $table->text('value');++ $table->foreign('rt_id')->references('id')->on('recurrences_transactions')->onDelete('cascade');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "rt_meta": %s', $e->getMessage()));+ Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');}- );-} catch (QueryException $e) {- Log::error(sprintf('Could not create table "rt_meta": %s', $e->getMessage()));- Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');-}}}diff --git a/database/migrations/2018_09_05_195147_changes_for_v477.php b/database/migrations/2018_09_05_195147_changes_for_v477.phpindex 3db1986b8f..be9f4e233b 100644--- a/database/migrations/2018_09_05_195147_changes_for_v477.php+++ b/database/migrations/2018_09_05_195147_changes_for_v477.php@@ -22,7 +22,9 @@declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;/**@@ -39,17 +41,22 @@ class ChangesForV477 extends Migration*/public function down(): void{- Schema::table(- 'budget_limits',- static function (Blueprint $table) {- // cannot drop foreign keys in SQLite:- if ('sqlite' !== config('database.default')) {- $table->dropForeign('budget_limits_transaction_currency_id_foreign');- }+ try {+ Schema::table(+ 'budget_limits',+ static function (Blueprint $table) {+ // cannot drop foreign keys in SQLite:+ if ('sqlite' !== config('database.default')) {+ $table->dropForeign('budget_limits_transaction_currency_id_foreign');+ }- $table->dropColumn(['transaction_currency_id']);- }- );+ $table->dropColumn(['transaction_currency_id']);+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -60,12 +67,17 @@ class ChangesForV477 extends Migration*/public function up(): void{- Schema::table(- 'budget_limits',- static function (Blueprint $table) {- $table->integer('transaction_currency_id', false, true)->nullable()->after('budget_id');- $table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');- }- );+ try {+ Schema::table(+ 'budget_limits',+ static function (Blueprint $table) {+ $table->integer('transaction_currency_id', false, true)->nullable()->after('budget_id');+ $table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2018_11_06_172532_changes_for_v479.php b/database/migrations/2018_11_06_172532_changes_for_v479.phpindex 63c6507247..6445235f96 100644--- a/database/migrations/2018_11_06_172532_changes_for_v479.php+++ b/database/migrations/2018_11_06_172532_changes_for_v479.php@@ -22,7 +22,9 @@declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;/**@@ -39,12 +41,17 @@ class ChangesForV479 extends Migration*/public function down(): void{- Schema::table(- 'transaction_currencies',- static function (Blueprint $table) {- $table->dropColumn(['enabled']);- }- );+ try {+ Schema::table(+ 'transaction_currencies',+ static function (Blueprint $table) {+ $table->dropColumn(['enabled']);+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -55,11 +62,16 @@ class ChangesForV479 extends Migration*/public function up(): void{- Schema::table(- 'transaction_currencies',- static function (Blueprint $table) {- $table->boolean('enabled')->default(0)->after('deleted_at');- }- );+ try {+ Schema::table(+ 'transaction_currencies',+ static function (Blueprint $table) {+ $table->boolean('enabled')->default(0)->after('deleted_at');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2019_02_05_055516_changes_for_v4711.php b/database/migrations/2019_02_05_055516_changes_for_v4711.phpindex 430f23f0e9..5715ecd269 100644--- a/database/migrations/2019_02_05_055516_changes_for_v4711.php+++ b/database/migrations/2019_02_05_055516_changes_for_v4711.php@@ -23,6 +23,7 @@declare(strict_types=1);use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;@@ -59,18 +60,28 @@ class ChangesForV4711 extends Migration* datetime (without a time zone) for all database engines because MySQL refuses to play* nice.*/- Schema::table(- 'transaction_journals',- static function (Blueprint $table) {- $table->dateTime('date')->change();- }- );+ try {+ Schema::table(+ 'transaction_journals',+ static function (Blueprint $table) {+ $table->dateTime('date')->change();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }- Schema::table(- 'preferences',- static function (Blueprint $table) {- $table->text('data')->nullable()->change();- }- );+ try {+ Schema::table(+ 'preferences',+ static function (Blueprint $table) {+ $table->text('data')->nullable()->change();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2019_02_11_170529_changes_for_v4712.php b/database/migrations/2019_02_11_170529_changes_for_v4712.phpindex 09c3bb4910..0ebfe1c77c 100644--- a/database/migrations/2019_02_11_170529_changes_for_v4712.php+++ b/database/migrations/2019_02_11_170529_changes_for_v4712.php@@ -22,6 +22,7 @@declare(strict_types=1);use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;@@ -58,11 +59,16 @@ class ChangesForV4712 extends Migration* datetime (without a time zone) for all database engines because MySQL refuses to play* nice.*/- Schema::table(- 'transaction_journals',- static function (Blueprint $table) {- $table->dateTime('date')->change();- }- );+ try {+ Schema::table(+ 'transaction_journals',+ static function (Blueprint $table) {+ $table->dateTime('date')->change();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2019_03_11_223700_fix_ldap_configuration.php b/database/migrations/2019_03_11_223700_fix_ldap_configuration.phpindex bbf7a89207..7eea9dd17a 100644--- a/database/migrations/2019_03_11_223700_fix_ldap_configuration.php+++ b/database/migrations/2019_03_11_223700_fix_ldap_configuration.php@@ -21,7 +21,9 @@declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;@@ -39,12 +41,17 @@ class FixLdapConfiguration extends Migration*/public function down(): void{- Schema::table(- 'users',- static function (Blueprint $table) {- $table->dropColumn(['objectguid']);- }- );+ try {+ Schema::table(+ 'users',+ static function (Blueprint $table) {+ $table->dropColumn(['objectguid']);+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -59,11 +66,16 @@ class FixLdapConfiguration extends Migration* ADLdap2 appears to require the ability to store an objectguid for LDAP users* now. To support this, we add the column.*/- Schema::table(- 'users',- static function (Blueprint $table) {- $table->uuid('objectguid')->nullable()->after('id');- }- );+ try {+ Schema::table(+ 'users',+ static function (Blueprint $table) {+ $table->uuid('objectguid')->nullable()->after('id');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2019_03_22_183214_changes_for_v480.php b/database/migrations/2019_03_22_183214_changes_for_v480.phpindex 825cfbecb6..6acb6ebb28 100644--- a/database/migrations/2019_03_22_183214_changes_for_v480.php+++ b/database/migrations/2019_03_22_183214_changes_for_v480.php@@ -21,7 +21,9 @@declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;/**@@ -38,30 +40,66 @@ class ChangesForV480 extends Migration*/public function down(): void{- Schema::table(- 'transaction_journals',- static function (Blueprint $table) {- // drop transaction_group_id + foreign key.- // cannot drop foreign keys in SQLite:- if ('sqlite' !== config('database.default')) {- $table->dropForeign('transaction_journals_transaction_group_id_foreign');+ try {+ Schema::table(+ 'transaction_journals',+ static function (Blueprint $table) {+ // drop transaction_group_id + foreign key.+ // cannot drop foreign keys in SQLite:+ if ('sqlite' !== config('database.default')) {+ try {+ $table->dropForeign('transaction_journals_transaction_group_id_foreign');+ } catch (QueryException $e) {+ Log::error(sprintf('Could not drop foreign ID: %s', $e->getMessage()));+ Log::error('If the foreign ID does not exist (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }+ }+ try {+ $table->dropColumn('transaction_group_id');+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not drop column: %s', $e->getMessage()));+ Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');+ }}- $table->dropColumn('transaction_group_id');- }- );- Schema::table(- 'rule_groups',- static function (Blueprint $table) {- $table->dropColumn('stop_processing');- }- );+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }- Schema::table(- 'users',- static function (Blueprint $table) {- $table->dropColumn('mfa_secret');- }- );+ try {+ Schema::table(+ 'rule_groups',+ static function (Blueprint $table) {+ try {+ $table->dropColumn('stop_processing');+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not drop column: %s', $e->getMessage()));+ Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');+ }+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }++ try {+ Schema::table(+ 'users',+ static function (Blueprint $table) {+ try {+ $table->dropColumn('mfa_secret');+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not drop column: %s', $e->getMessage()));+ Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');+ }+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -72,30 +110,52 @@ class ChangesForV480 extends Migration*/public function up(): void{- Schema::table(- 'transaction_journals',- static function (Blueprint $table) {- $table->integer('transaction_currency_id', false, true)->nullable()->change();+ try {+ Schema::table(+ 'transaction_journals',+ static function (Blueprint $table) {+ $table->integer('transaction_currency_id', false, true)->nullable()->change();- // add column "group_id" after "transaction_type_id"- $table->integer('transaction_group_id', false, true)- ->nullable()->default(null)->after('transaction_type_id');+ // add column "group_id" after "transaction_type_id"+ $table->integer('transaction_group_id', false, true)+ ->nullable()->default(null)->after('transaction_type_id');- // add foreign key for "transaction_group_id"- $table->foreign('transaction_group_id')->references('id')->on('transaction_groups')->onDelete('cascade');- }- );- Schema::table(- 'rule_groups',- static function (Blueprint $table) {- $table->boolean('stop_processing')->default(false);- }- );- Schema::table(- 'users',- static function (Blueprint $table) {- $table->string('mfa_secret', 50)->nullable();- }- );+ // add foreign key for "transaction_group_id"+ try {+ $table->foreign('transaction_group_id')->references('id')->on('transaction_groups')->onDelete('cascade');+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create foreign index: %s', $e->getMessage()));+ Log::error(+ 'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'+ );+ }+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }+ try {+ Schema::table(+ 'rule_groups',+ static function (Blueprint $table) {+ $table->boolean('stop_processing')->default(false);+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }+ try {+ Schema::table(+ 'users',+ static function (Blueprint $table) {+ $table->string('mfa_secret', 50)->nullable();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2020_06_30_202620_changes_for_v530a.php b/database/migrations/2020_06_30_202620_changes_for_v530a.phpindex b54a7144cc..eee512a65c 100644--- a/database/migrations/2020_06_30_202620_changes_for_v530a.php+++ b/database/migrations/2020_06_30_202620_changes_for_v530a.php@@ -22,7 +22,9 @@declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;@@ -40,12 +42,17 @@ class ChangesForV530a extends Migration*/public function down(): void{- Schema::table(- 'bills',- static function (Blueprint $table) {- $table->dropColumn('order');- }- );+ try {+ Schema::table(+ 'bills',+ static function (Blueprint $table) {+ $table->dropColumn('order');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -55,11 +62,16 @@ class ChangesForV530a extends Migration*/public function up(): void{- Schema::table(- 'bills',- static function (Blueprint $table) {- $table->integer('order', false, true)->default(0);- }- );+ try {+ Schema::table(+ 'bills',+ static function (Blueprint $table) {+ $table->integer('order', false, true)->default(0);+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2020_07_24_162820_changes_for_v540.php b/database/migrations/2020_07_24_162820_changes_for_v540.phpindex 38401fba0a..8d3d78eb92 100644--- a/database/migrations/2020_07_24_162820_changes_for_v540.php+++ b/database/migrations/2020_07_24_162820_changes_for_v540.php@@ -22,7 +22,9 @@declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;@@ -40,27 +42,43 @@ class ChangesForV540 extends Migration*/public function down(): void{- Schema::table(- 'oauth_clients',- static function (Blueprint $table) {- $table->dropColumn('provider');- }- );+ try {+ Schema::table(+ 'oauth_clients',+ static function (Blueprint $table) {+ $table->dropColumn('provider');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }- Schema::table(- 'accounts',- static function (Blueprint $table) {- $table->dropColumn('order');- }- );+ try {+ Schema::table(+ 'accounts',+ static function (Blueprint $table) {+ $table->dropColumn('order');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }- Schema::table(- 'bills',- static function (Blueprint $table) {- $table->dropColumn('end_date');- $table->dropColumn('extension_date');- }- );+ try {+ Schema::table(+ 'bills',+ static function (Blueprint $table) {+ $table->dropColumn('end_date');++ $table->dropColumn('extension_date');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -70,31 +88,51 @@ class ChangesForV540 extends Migration*/public function up(): void{- Schema::table(- 'accounts',- static function (Blueprint $table) {- $table->integer('order', false, true)->default(0);- }- );- Schema::table(- 'oauth_clients',- static function (Blueprint $table) {- $table->string('provider')->nullable();- }- );- Schema::table(- 'bills',- static function (Blueprint $table) {- $table->date('end_date')->nullable()->after('date');- $table->date('extension_date')->nullable()->after('end_date');- }- );+ try {+ Schema::table(+ 'accounts',+ static function (Blueprint $table) {+ $table->integer('order', false, true)->default(0);+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }+ try {+ Schema::table(+ 'oauth_clients',+ static function (Blueprint $table) {+ $table->string('provider')->nullable();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }+ try {+ Schema::table(+ 'bills',+ static function (Blueprint $table) {+ $table->date('end_date')->nullable()->after('date');+ $table->date('extension_date')->nullable()->after('end_date');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }// make column nullable:- Schema::table(- 'oauth_clients',- function (Blueprint $table) {- $table->string('secret', 100)->nullable()->change();- }- );+ try {+ Schema::table(+ 'oauth_clients',+ function (Blueprint $table) {+ $table->string('secret', 100)->nullable()->change();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2020_11_12_070604_changes_for_v550.php b/database/migrations/2020_11_12_070604_changes_for_v550.phpindex 1c7c5d7efa..02e894715c 100644--- a/database/migrations/2020_11_12_070604_changes_for_v550.php+++ b/database/migrations/2020_11_12_070604_changes_for_v550.php@@ -22,6 +22,7 @@declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;@@ -64,25 +65,35 @@ class ChangesForV550 extends Migration}// expand budget / transaction journal table.- Schema::table(- 'budget_transaction_journal',- function (Blueprint $table) {- $table->dropForeign('budget_id_foreign');- $table->dropColumn('budget_limit_id');- }- );+ try {+ Schema::table(+ 'budget_transaction_journal',+ function (Blueprint $table) {+ $table->dropForeign('budget_id_foreign');+ $table->dropColumn('budget_limit_id');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }// drop failed jobs table.Schema::dropIfExists('failed_jobs');// drop fields from budget limits- Schema::table(- 'budget_limits',- static function (Blueprint $table) {- $table->dropColumn('period');- $table->dropColumn('generated');- }- );+ try {+ Schema::table(+ 'budget_limits',+ static function (Blueprint $table) {+ $table->dropColumn('period');+ $table->dropColumn('generated');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }Schema::dropIfExists('webhook_attempts');Schema::dropIfExists('webhook_messages');Schema::dropIfExists('webhooks');@@ -138,29 +149,39 @@ class ChangesForV550 extends Migration}// update budget / transaction journal table.- Schema::table(- 'budget_transaction_journal',- function (Blueprint $table) {- if (!Schema::hasColumn('budget_transaction_journal', 'budget_limit_id')) {- $table->integer('budget_limit_id', false, true)->nullable()->default(null)->after('budget_id');- $table->foreign('budget_limit_id', 'budget_id_foreign')->references('id')->on('budget_limits')->onDelete('set null');+ try {+ Schema::table(+ 'budget_transaction_journal',+ function (Blueprint $table) {+ if (!Schema::hasColumn('budget_transaction_journal', 'budget_limit_id')) {+ $table->integer('budget_limit_id', false, true)->nullable()->default(null)->after('budget_id');+ $table->foreign('budget_limit_id', 'budget_id_foreign')->references('id')->on('budget_limits')->onDelete('set null');+ }}- }- );+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }// append budget limits table.// i swear I dropped & recreated this field 15 times already.- Schema::table(- 'budget_limits',- static function (Blueprint $table) {- if (!Schema::hasColumn('budget_limits', 'period')) {- $table->string('period', 12)->nullable();- }- if (!Schema::hasColumn('budget_limits', 'generated')) {- $table->boolean('generated')->default(false);+ try {+ Schema::table(+ 'budget_limits',+ static function (Blueprint $table) {+ if (!Schema::hasColumn('budget_limits', 'period')) {+ $table->string('period', 12)->nullable();+ }+ if (!Schema::hasColumn('budget_limits', 'generated')) {+ $table->boolean('generated')->default(false);+ }}- }- );+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }// new webhooks tableif (!Schema::hasTable('webhooks')) {diff --git a/database/migrations/2021_03_12_061213_changes_for_v550b2.php b/database/migrations/2021_03_12_061213_changes_for_v550b2.phpindex 4b3a97a1b2..94a08bc4fb 100644--- a/database/migrations/2021_03_12_061213_changes_for_v550b2.php+++ b/database/migrations/2021_03_12_061213_changes_for_v550b2.php@@ -22,7 +22,9 @@declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;@@ -38,15 +40,20 @@ class ChangesForV550b2 extends Migration*/public function down(): void{- Schema::table(- 'recurrences_transactions',- function (Blueprint $table) {- $table->dropForeign('type_foreign');- if (Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {- $table->dropColumn('transaction_type_id');+ try {+ Schema::table(+ 'recurrences_transactions',+ function (Blueprint $table) {+ $table->dropForeign('type_foreign');+ if (Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {+ $table->dropColumn('transaction_type_id');+ }}- }- );+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -57,14 +64,19 @@ class ChangesForV550b2 extends Migrationpublic function up(): void{// expand recurrence transaction table- Schema::table(- 'recurrences_transactions',- function (Blueprint $table) {- 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');+ try {+ Schema::table(+ 'recurrences_transactions',+ function (Blueprint $table) {+ 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');+ }}- }- );+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2021_05_09_064644_add_ldap_columns_to_users_table.php b/database/migrations/2021_05_09_064644_add_ldap_columns_to_users_table.phpindex 31c5990a2e..763b51ca5b 100644--- a/database/migrations/2021_05_09_064644_add_ldap_columns_to_users_table.php+++ b/database/migrations/2021_05_09_064644_add_ldap_columns_to_users_table.php@@ -22,7 +22,9 @@declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;@@ -33,12 +35,17 @@ class AddLdapColumnsToUsersTable extends Migration*/public function down(): void{- Schema::table(- 'users',- function (Blueprint $table) {- $table->dropColumn(['domain']);- }- );+ try {+ Schema::table(+ 'users',+ function (Blueprint $table) {+ $table->dropColumn(['domain']);+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -46,11 +53,16 @@ class AddLdapColumnsToUsersTable extends Migration*/public function up(): void{- Schema::table(- 'users',- function (Blueprint $table) {- $table->string('domain')->nullable();- }- );+ try {+ Schema::table(+ 'users',+ function (Blueprint $table) {+ $table->string('domain')->nullable();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2021_05_13_053836_extend_currency_info.php b/database/migrations/2021_05_13_053836_extend_currency_info.phpindex 8ed890315b..b2982f6154 100644--- a/database/migrations/2021_05_13_053836_extend_currency_info.php+++ b/database/migrations/2021_05_13_053836_extend_currency_info.php@@ -23,6 +23,7 @@declare(strict_types=1);use Illuminate\Database\Migrations\Migration;+use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;use Illuminate\Support\Facades\Schema;@@ -48,12 +49,17 @@ class ExtendCurrencyInfo extends Migration*/public function up(): void{- Schema::table(- 'transaction_currencies',- function (Blueprint $table) {- $table->string('code', 51)->change();- $table->string('symbol', 51)->change();- }- );+ try {+ Schema::table(+ 'transaction_currencies',+ function (Blueprint $table) {+ $table->string('code', 51)->change();+ $table->string('symbol', 51)->change();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}diff --git a/database/migrations/2021_08_28_073733_user_groups.php b/database/migrations/2021_08_28_073733_user_groups.phpindex ba38865148..ca3b597aa7 100644--- a/database/migrations/2021_08_28_073733_user_groups.php+++ b/database/migrations/2021_08_28_073733_user_groups.php@@ -22,6 +22,7 @@declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;@@ -59,27 +60,37 @@ class UserGroups extends Migration// remove columns from tables/** @var string $tableName */foreach ($this->tables as $tableName) {+ try {+ Schema::table(+ $tableName,+ function (Blueprint $table) use ($tableName) {+ $table->dropForeign(sprintf('%s_to_ugi', $tableName));+ if (Schema::hasColumn($tableName, 'user_group_id')) {+ $table->dropColumn('user_group_id');+ }+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }+ }++ try {Schema::table(- $tableName,- function (Blueprint $table) use ($tableName) {- $table->dropForeign(sprintf('%s_to_ugi', $tableName));- if (Schema::hasColumn($tableName, 'user_group_id')) {+ 'users',+ function (Blueprint $table) {+ $table->dropForeign('type_user_group_id');+ if (Schema::hasColumn('users', 'user_group_id')) {$table->dropColumn('user_group_id');}});+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');}- Schema::table(- 'users',- function (Blueprint $table) {- $table->dropForeign('type_user_group_id');- if (Schema::hasColumn('users', 'user_group_id')) {- $table->dropColumn('user_group_id');- }- }- );-Schema::dropIfExists('group_memberships');Schema::dropIfExists('user_roles');Schema::dropIfExists('user_groups');@@ -150,30 +161,40 @@ class UserGroups extends MigrationLog::error(sprintf('Could not create table "group_memberships": %s', $e->getMessage()));Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');}- Schema::table(- 'users',- function (Blueprint $table) {- if (!Schema::hasColumn('users', 'user_group_id')) {- $table->bigInteger('user_group_id', false, true)->nullable();- $table->foreign('user_group_id', 'type_user_group_id')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');+ try {+ Schema::table(+ 'users',+ function (Blueprint $table) {+ if (!Schema::hasColumn('users', 'user_group_id')) {+ $table->bigInteger('user_group_id', false, true)->nullable();+ $table->foreign('user_group_id', 'type_user_group_id')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');+ }}- }- );+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }// ADD columns from tables/** @var string $tableName */foreach ($this->tables as $tableName) {- Schema::table(- $tableName,- function (Blueprint $table) use ($tableName) {- if (!Schema::hasColumn($tableName, 'user_group_id')) {- $table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');- $table->foreign('user_group_id', sprintf('%s_to_ugi', $tableName))->references('id')->on('user_groups')->onDelete('set null')->onUpdate(- 'cascade'- );+ try {+ Schema::table(+ $tableName,+ function (Blueprint $table) use ($tableName) {+ if (!Schema::hasColumn($tableName, 'user_group_id')) {+ $table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');+ $table->foreign('user_group_id', sprintf('%s_to_ugi', $tableName))->references('id')->on('user_groups')->onDelete(+ 'set null'+ )->onUpdate('cascade');+ }}- }- );+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}}diff --git a/database/migrations/2022_08_21_104626_add_user_groups.php b/database/migrations/2022_08_21_104626_add_user_groups.phpindex a79b1f7fae..30454d1b20 100644--- a/database/migrations/2022_08_21_104626_add_user_groups.php+++ b/database/migrations/2022_08_21_104626_add_user_groups.php@@ -22,6 +22,7 @@declare(strict_types=1);+use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;use Illuminate\Database\Migrations\Migration;use Illuminate\Database\QueryException;use Illuminate\Database\Schema\Blueprint;@@ -39,25 +40,20 @@ return new class () extends Migration {*/public function up(): void{- Schema::table(- 'currency_exchange_rates',- function (Blueprint $table) {- if (!Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {- try {+ try {+ Schema::table(+ 'currency_exchange_rates',+ function (Blueprint $table) {+ if (!Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');- } catch (QueryException $e) {- Log::error(sprintf('Could not add column "user_group_id" to table "currency_exchange_rates": %s', $e->getMessage()));- Log::error('If the column exists already (see error), this is not a problem. Otherwise, please create a GitHub discussion.');- }- try {$table->foreign('user_group_id', 'cer_to_ugi')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');- } catch (QueryException $e) {- Log::error(sprintf('Could not add foreign key "cer_to_ugi" to table "currency_exchange_rates": %s', $e->getMessage()));- Log::error('If the foreign key exists already (see error), this is not a problem. Otherwise, please create a GitHub discussion.');}}- }- );+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}/**@@ -67,24 +63,19 @@ return new class () extends Migration {*/public function down(): void{- Schema::table(- 'currency_exchange_rates',- function (Blueprint $table) {- try {+ try {+ Schema::table(+ 'currency_exchange_rates',+ function (Blueprint $table) {$table->dropForeign('cer_to_ugi');- } catch (QueryException $e) {- Log::error(sprintf('Could not drop foreign key "cer_to_ugi" from table "currency_exchange_rates": %s', $e->getMessage()));- Log::error('If the foreign key does not exist (see error message), this is not a problem. Otherwise, please create a GitHub discussion.');- }- if (Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {- try {+ if (Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {$table->dropColumn('user_group_id');- } catch (QueryException $e) {- Log::error(sprintf('Could not drop column "user_group_id" from table "currency_exchange_rates": %s', $e->getMessage()));- Log::error('If the column does not exist (see error message), this is not a problem. Otherwise, please create a GitHub discussion.');}}- }- );+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not execute query: %s', $e->getMessage()));+ Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');+ }}};