Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Catch all possible migration errors
James Colead97e33ec0b9
diff --git a/app/Console/Commands/ForceDecimalSize.php b/app/Console/Commands/ForceDecimalSize.phpindex 07eae60f15..e8b601eafd 100644--- a/app/Console/Commands/ForceDecimalSize.php+++ b/app/Console/Commands/ForceDecimalSize.php@@ -1,5 +1,7 @@<?php+declare(strict_types=1);+namespace FireflyIII\Console\Commands;use FireflyIII\Exceptions\FireflyException;@@ -9,7 +11,7 @@ use Illuminate\Support\Facades\Log;class ForceDecimalSize extends Command{-use VerifiesAccessToken;+ use VerifiesAccessToken;/*** The name and signature of the console command.*diff --git a/app/Models/UserGroup.php b/app/Models/UserGroup.phpindex e36fcce74a..5406d86c0b 100644--- a/app/Models/UserGroup.php+++ b/app/Models/UserGroup.php@@ -52,6 +52,7 @@ use Illuminate\Support\Carbon;* @property-read Collection<int, \FireflyIII\Models\Account> $accounts* @property-read int|null $accounts_count* @property-read Collection<int, \FireflyIII\Models\Account> $accounts+ * @property-read Collection<int, \FireflyIII\Models\Account> $accounts* @mixin Eloquent*/class UserGroup extends Modeldiff --git a/composer.lock b/composer.lockindex 7afe7585b9..0f35777557 100644--- a/composer.lock+++ b/composer.lock@@ -4075,16 +4075,16 @@},{"name": "nyholm/psr7",- "version": "1.5.1",+ "version": "1.6.0","source": {"type": "git","url": "https://github.com/Nyholm/psr7.git",- "reference": "f734364e38a876a23be4d906a2a089e1315be18a"+ "reference": "bf4aebd170fadf5fd808c70b90535de327e81a50"},"dist": {"type": "zip",- "url": "https://api.github.com/repos/Nyholm/psr7/zipball/f734364e38a876a23be4d906a2a089e1315be18a",- "reference": "f734364e38a876a23be4d906a2a089e1315be18a",+ "url": "https://api.github.com/repos/Nyholm/psr7/zipball/bf4aebd170fadf5fd808c70b90535de327e81a50",+ "reference": "bf4aebd170fadf5fd808c70b90535de327e81a50","shasum": ""},"require": {@@ -4094,6 +4094,7 @@"psr/http-message": "^1.0"},"provide": {+ "php-http/message-factory-implementation": "1.0","psr/http-factory-implementation": "1.0","psr/http-message-implementation": "1.0"},@@ -4106,7 +4107,7 @@"type": "library","extra": {"branch-alias": {- "dev-master": "1.4-dev"+ "dev-master": "1.6-dev"}},"autoload": {@@ -4136,7 +4137,7 @@],"support": {"issues": "https://github.com/Nyholm/psr7/issues",- "source": "https://github.com/Nyholm/psr7/tree/1.5.1"+ "source": "https://github.com/Nyholm/psr7/tree/1.6.0"},"funding": [{@@ -4148,7 +4149,7 @@"type": "github"}],- "time": "2022-06-22T07:13:36+00:00"+ "time": "2023-04-09T08:34:27+00:00"},{"name": "paragonie/constant_time_encoding",diff --git a/database/migrations/2016_09_12_121359_fix_nullables.php b/database/migrations/2016_09_12_121359_fix_nullables.phpindex 9ce6656a67..e1b55ca23b 100644--- a/database/migrations/2016_09_12_121359_fix_nullables.php+++ b/database/migrations/2016_09_12_121359_fix_nullables.php@@ -45,28 +45,32 @@ class FixNullables extends Migration*/public function up(): void{- 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.');+ if (!Schema::hasColumn('rule_groups', 'description')) {+ 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.');+ }}- 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.');+ if (!Schema::hasColumn('rules', 'description')) {+ 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 7da82ca873..0a91c74d5a 100644--- a/database/migrations/2016_10_09_150037_expand_transactions_table.php+++ b/database/migrations/2016_10_09_150037_expand_transactions_table.php@@ -38,16 +38,18 @@ class ExpandTransactionsTable extends Migration*/public function down(): void{- 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.');+ if (Schema::hasColumn('transactions', 'identifier')) {+ try {+ Schema::table(+ 'transactions',+ static function (Blueprint $table) {+ $table->dropColumn('identifier');+ }+ );+ } catch (QueryException|ColumnDoesNotExist $e) {+ Log::error(sprintf('Could not drop column "identifier": %s', $e->getMessage()));+ Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');+ }}}@@ -57,16 +59,18 @@ class ExpandTransactionsTable extends Migration*/public function up(): void{- 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.');+ if (!Schema::hasColumn('transactions', 'identifier')) {+ 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_10_22_075804_changes_for_v410.php b/database/migrations/2016_10_22_075804_changes_for_v410.phpindex a4577a7382..9979235e54 100644--- a/database/migrations/2016_10_22_075804_changes_for_v410.php+++ b/database/migrations/2016_10_22_075804_changes_for_v410.php@@ -46,22 +46,24 @@ class ChangesForV410 extends Migration*/public function up(): void{- try {- Schema::create(- 'notes',- static function (Blueprint $table) {- $table->increments('id');- $table->timestamps();- $table->softDeletes();- $table->integer('noteable_id', false, true);- $table->string('noteable_type');- $table->string('title')->nullable();- $table->text('text')->nullable();- }- );- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "notes": %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.');+ if(!Schema::hasTable('notes')) {+ try {+ Schema::create(+ 'notes',+ static function (Blueprint $table) {+ $table->increments('id');+ $table->timestamps();+ $table->softDeletes();+ $table->integer('noteable_id', false, true);+ $table->string('noteable_type');+ $table->string('title')->nullable();+ $table->text('text')->nullable();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "notes": %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/2016_11_24_210552_changes_for_v420.php b/database/migrations/2016_11_24_210552_changes_for_v420.phpindex a63dc918d8..48f23e4561 100644--- a/database/migrations/2016_11_24_210552_changes_for_v420.php+++ b/database/migrations/2016_11_24_210552_changes_for_v420.php@@ -37,16 +37,18 @@ class ChangesForV420 extends Migration*/public function down(): void{- 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.');+ if (Schema::hasColumn('journal_meta', 'deleted_at')) {+ 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.');+ }}}@@ -56,16 +58,18 @@ class ChangesForV420 extends Migration*/public function up(): void{- 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.');+ if (!Schema::hasColumn('journal_meta', 'deleted_at')) {+ 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_22_150431_changes_for_v430.php b/database/migrations/2016_12_22_150431_changes_for_v430.phpindex ce7151e782..36e49e1118 100644--- a/database/migrations/2016_12_22_150431_changes_for_v430.php+++ b/database/migrations/2016_12_22_150431_changes_for_v430.php@@ -46,26 +46,28 @@ class ChangesForV430 extends Migration*/public function up(): void{- try {- Schema::create(- 'available_budgets',- static function (Blueprint $table) {- $table->increments('id');- $table->timestamps();- $table->softDeletes();- $table->integer('user_id', false, true);- $table->integer('transaction_currency_id', false, true);- $table->decimal('amount', 32, 12);- $table->date('start_date');- $table->date('end_date');+ if (!Schema::hasTable('available_budgets')) {+ try {+ Schema::create(+ 'available_budgets',+ static function (Blueprint $table) {+ $table->increments('id');+ $table->timestamps();+ $table->softDeletes();+ $table->integer('user_id', false, true);+ $table->integer('transaction_currency_id', false, true);+ $table->decimal('amount', 32, 12);+ $table->date('start_date');+ $table->date('end_date');- $table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');- $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');- }- );- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "available_budgets": %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.');+ $table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');+ $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "available_budgets": %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/2016_12_28_203205_changes_for_v431.php b/database/migrations/2016_12_28_203205_changes_for_v431.phpindex 071d9f7da3..d7d4e36d16 100644--- a/database/migrations/2016_12_28_203205_changes_for_v431.php+++ b/database/migrations/2016_12_28_203205_changes_for_v431.php@@ -39,65 +39,74 @@ class ChangesForV431 extends Migrationpublic function down(): void{// reinstate "repeats" and "repeat_freq".- 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.');+ if (!Schema::hasColumn('budget_limits', 'repeat_freq')) {+ 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.');+ if (!Schema::hasColumn('budget_limits', 'repeats')) {+ 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"- 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.');+ if (Schema::hasColumn('budget_limits', 'start_date') && !Schema::hasColumn('budget_limits', '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"- 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.');+ if (Schema::hasColumn('budget_limits', '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- 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.');+ if (Schema::hasColumn('transaction_currencies', '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.');+ }}}@@ -108,66 +117,76 @@ class ChangesForV431 extends Migrationpublic function up(): void{// add decimal places to "transaction currencies".- 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.');+ if (!Schema::hasColumn('transaction_currencies', 'decimal_places')) {+ 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"- 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.');+ if (Schema::hasColumn('budget_limits', 'startdate') && !Schema::hasColumn('budget_limits', '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"- 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.');+ if (!Schema::hasColumn('budget_limits', 'end_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".- 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.');+ if (Schema::hasColumn('budget_limits', 'repeats')) {+ 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.');+ if (Schema::hasColumn('budget_limits', 'repeat_freq')) {+ 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 8275d52e05..d74d4d81ca 100644--- a/database/migrations/2017_04_13_163623_changes_for_v440.php+++ b/database/migrations/2017_04_13_163623_changes_for_v440.php@@ -89,20 +89,21 @@ class ChangesForV440 extends MigrationLog::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::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');+ if(!Schema::hasColumn('transactions', 'transaction_currency_id')) {+ 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.');+ );+ } 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 df70628ed4..572a154d13 100644--- a/database/migrations/2017_06_02_105232_changes_for_v450.php+++ b/database/migrations/2017_06_02_105232_changes_for_v450.php@@ -39,16 +39,18 @@ class ChangesForV450 extends Migrationpublic function down(): void{// split up for sqlite compatibility- 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.');+ if(Schema::hasColumn('transactions', '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.');+ }}try {@@ -65,17 +67,18 @@ class ChangesForV450 extends MigrationLog::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(- '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.');+ if(Schema::hasColumn('transactions', '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.');+ }}}@@ -86,30 +89,34 @@ class ChangesForV450 extends Migrationpublic function up(): void{// add "foreign_amount" to transactions- 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.');+ if(!Schema::hasColumn('transactions', 'foreign_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):- 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.');+ if(!Schema::hasColumn('transactions', 'foreign_currency_id')) {+ 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 89fdb9fd96..92a32e5dd3 100644--- a/database/migrations/2017_11_04_170844_changes_for_v470a.php+++ b/database/migrations/2017_11_04_170844_changes_for_v470a.php@@ -39,16 +39,18 @@ class ChangesForV470a extends Migration*/public function down(): void{- 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.');+ if (Schema::hasColumn('transactions', '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.');+ }}}@@ -58,16 +60,18 @@ class ChangesForV470a extends Migration*/public function up(): void{- 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.');+ if (!Schema::hasColumn('transactions', 'reconciled')) {+ 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_01_01_000001_create_oauth_auth_codes_table.php b/database/migrations/2018_01_01_000001_create_oauth_auth_codes_table.phpindex 264897024b..1b11da602e 100644--- a/database/migrations/2018_01_01_000001_create_oauth_auth_codes_table.php+++ b/database/migrations/2018_01_01_000001_create_oauth_auth_codes_table.php@@ -47,21 +47,23 @@ class CreateOauthAuthCodesTable extends Migration*/public function up(): void{- try {- Schema::create(- 'oauth_auth_codes',- static function (Blueprint $table) {- $table->string('id', 100)->primary();- $table->integer('user_id');- $table->integer('client_id');- $table->text('scopes')->nullable();- $table->boolean('revoked');- $table->dateTime('expires_at')->nullable();- }- );- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "oauth_auth_codes": %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.');+ if(!Schema::hasTable('oauth_auth_codes')) {+ try {+ Schema::create(+ 'oauth_auth_codes',+ static function (Blueprint $table) {+ $table->string('id', 100)->primary();+ $table->integer('user_id');+ $table->integer('client_id');+ $table->text('scopes')->nullable();+ $table->boolean('revoked');+ $table->dateTime('expires_at')->nullable();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "oauth_auth_codes": %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_01_01_000002_create_oauth_access_tokens_table.php b/database/migrations/2018_01_01_000002_create_oauth_access_tokens_table.phpindex d5d83e8ed1..d23bf407dd 100644--- a/database/migrations/2018_01_01_000002_create_oauth_access_tokens_table.php+++ b/database/migrations/2018_01_01_000002_create_oauth_access_tokens_table.php@@ -47,23 +47,25 @@ class CreateOauthAccessTokensTable extends Migration*/public function up(): void{- try {- Schema::create(- 'oauth_access_tokens',- static function (Blueprint $table) {- $table->string('id', 100)->primary();- $table->integer('user_id')->index()->nullable();- $table->integer('client_id');- $table->string('name')->nullable();- $table->text('scopes')->nullable();- $table->boolean('revoked');- $table->timestamps();- $table->dateTime('expires_at')->nullable();- }- );- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "oauth_access_tokens": %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.');+ if(!Schema::hasTable('oauth_access_tokens')) {+ try {+ Schema::create(+ 'oauth_access_tokens',+ static function (Blueprint $table) {+ $table->string('id', 100)->primary();+ $table->integer('user_id')->index()->nullable();+ $table->integer('client_id');+ $table->string('name')->nullable();+ $table->text('scopes')->nullable();+ $table->boolean('revoked');+ $table->timestamps();+ $table->dateTime('expires_at')->nullable();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "oauth_access_tokens": %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_01_01_000003_create_oauth_refresh_tokens_table.php b/database/migrations/2018_01_01_000003_create_oauth_refresh_tokens_table.phpindex 9b06fe2b5a..c74233cec3 100644--- a/database/migrations/2018_01_01_000003_create_oauth_refresh_tokens_table.php+++ b/database/migrations/2018_01_01_000003_create_oauth_refresh_tokens_table.php@@ -47,19 +47,21 @@ class CreateOauthRefreshTokensTable extends Migration*/public function up(): void{- try {- Schema::create(- 'oauth_refresh_tokens',- static function (Blueprint $table) {- $table->string('id', 100)->primary();- $table->string('access_token_id', 100)->index();- $table->boolean('revoked');- $table->dateTime('expires_at')->nullable();- }- );- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "oauth_refresh_tokens": %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.');+ if(!Schema::hasTable('oauth_refresh_tokens')) {+ try {+ Schema::create(+ 'oauth_refresh_tokens',+ static function (Blueprint $table) {+ $table->string('id', 100)->primary();+ $table->string('access_token_id', 100)->index();+ $table->boolean('revoked');+ $table->dateTime('expires_at')->nullable();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "oauth_refresh_tokens": %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_01_01_000004_create_oauth_clients_table.php b/database/migrations/2018_01_01_000004_create_oauth_clients_table.phpindex ed30c4a50e..a0a260f367 100644--- a/database/migrations/2018_01_01_000004_create_oauth_clients_table.php+++ b/database/migrations/2018_01_01_000004_create_oauth_clients_table.php@@ -47,24 +47,26 @@ class CreateOauthClientsTable extends Migration*/public function up(): void{- try {- Schema::create(- 'oauth_clients',- static function (Blueprint $table) {- $table->increments('id');- $table->integer('user_id')->index()->nullable();- $table->string('name');- $table->string('secret', 100);- $table->text('redirect');- $table->boolean('personal_access_client');- $table->boolean('password_client');- $table->boolean('revoked');- $table->timestamps();- }- );- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "oauth_clients": %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.');+ if(!Schema::hasTable('oauth_clients')) {+ try {+ Schema::create(+ 'oauth_clients',+ static function (Blueprint $table) {+ $table->increments('id');+ $table->integer('user_id')->index()->nullable();+ $table->string('name');+ $table->string('secret', 100);+ $table->text('redirect');+ $table->boolean('personal_access_client');+ $table->boolean('password_client');+ $table->boolean('revoked');+ $table->timestamps();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "oauth_clients": %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_01_01_000005_create_oauth_personal_access_clients_table.php b/database/migrations/2018_01_01_000005_create_oauth_personal_access_clients_table.phpindex 7320a7c19d..3b12be0c67 100644--- a/database/migrations/2018_01_01_000005_create_oauth_personal_access_clients_table.php+++ b/database/migrations/2018_01_01_000005_create_oauth_personal_access_clients_table.php@@ -47,18 +47,20 @@ class CreateOauthPersonalAccessClientsTable extends Migration*/public function up(): void{- try {- Schema::create(- 'oauth_personal_access_clients',- static function (Blueprint $table) {- $table->increments('id');- $table->integer('client_id')->index();- $table->timestamps();- }- );- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "oauth_personal_access_clients": %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.');+ if(!Schema::hasTable('oauth_personal_access_clients')) {+ try {+ Schema::create(+ 'oauth_personal_access_clients',+ static function (Blueprint $table) {+ $table->increments('id');+ $table->integer('client_id')->index();+ $table->timestamps();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "oauth_personal_access_clients": %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_03_19_141348_changes_for_v472.php b/database/migrations/2018_03_19_141348_changes_for_v472.phpindex f9171aa21c..cfa7717406 100644--- a/database/migrations/2018_03_19_141348_changes_for_v472.php+++ b/database/migrations/2018_03_19_141348_changes_for_v472.php@@ -41,28 +41,32 @@ class ChangesForV472 extends Migration*/public function down(): void{- 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.');+ if(!Schema::hasColumn('attachments', 'notes')) {+ 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.');+ if(Schema::hasColumn('transactions', 'order')) {+ 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.');+ }}}@@ -73,28 +77,32 @@ class ChangesForV472 extends Migration*/public function up(): void{- 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.');+ if(Schema::hasColumn('attachments', '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.');+ }}- 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.');+ if(!Schema::hasColumn('budgets', 'order')) {+ 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 a9b5b08ccb..c471fbcf28 100644--- a/database/migrations/2018_04_07_210913_changes_for_v473.php+++ b/database/migrations/2018_04_07_210913_changes_for_v473.php@@ -42,33 +42,36 @@ class ChangesForV473 extends Migration*/public function down(): void{- 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');+ if(!Schema::hasColumn('bills', 'transaction_currency_id')) {+ 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.');+ );+ } 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(- '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.');+ if(!Schema::hasColumn('rules', '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.');+ }}}@@ -79,28 +82,32 @@ class ChangesForV473 extends Migration*/public function up(): void{- 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.');+ if(!Schema::hasColumn('bills', 'transaction_currency_id')) {+ 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.');+ if(!Schema::hasColumn('rules', 'strict')) {+ 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_06_08_200526_changes_for_v475.php b/database/migrations/2018_06_08_200526_changes_for_v475.phpindex 3d6b220284..249f6f76ec 100644--- a/database/migrations/2018_06_08_200526_changes_for_v475.php+++ b/database/migrations/2018_06_08_200526_changes_for_v475.php@@ -54,122 +54,133 @@ class ChangesForV475 extends Migration*/public function up(): void{- try {- Schema::create(- 'recurrences',- static function (Blueprint $table) {- $table->increments('id');- $table->timestamps();- $table->softDeletes();- $table->integer('user_id', false, true);- $table->integer('transaction_type_id', false, true);-- $table->string('title', 1024);- $table->text('description');-- $table->date('first_date');- $table->date('repeat_until')->nullable();- $table->date('latest_date')->nullable();- $table->smallInteger('repetitions', false, true);-- $table->boolean('apply_rules')->default(true);- $table->boolean('active')->default(true);-- $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');- $table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');- }- );- } catch (QueryException $e) {- Log::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.');+ if (!Schema::hasTable('recurrences')) {+ try {+ Schema::create(+ 'recurrences',+ static function (Blueprint $table) {+ $table->increments('id');+ $table->timestamps();+ $table->softDeletes();+ $table->integer('user_id', false, true);+ $table->integer('transaction_type_id', false, true);++ $table->string('title', 1024);+ $table->text('description');++ $table->date('first_date');+ $table->date('repeat_until')->nullable();+ $table->date('latest_date')->nullable();+ $table->smallInteger('repetitions', false, true);++ $table->boolean('apply_rules')->default(true);+ $table->boolean('active')->default(true);++ $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');+ $table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');+ }+ );+ } catch (QueryException $e) {+ Log::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');- }- );- } 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.');+ if (!Schema::hasTable('recurrences_transactions')) {+ 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.');+ }}- 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.');+ if (!Schema::hasTable('recurrences_repetitions')) {+ 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.');+ }}- 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->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.');+ if (!Schema::hasTable('recurrences_meta')) {+ 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->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.');+ }}- 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.');++ if (!Schema::hasTable('rt_meta')) {+ 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.');+ }}}}diff --git a/database/migrations/2018_09_05_195147_changes_for_v477.php b/database/migrations/2018_09_05_195147_changes_for_v477.phpindex 991396876d..c234d10f31 100644--- a/database/migrations/2018_09_05_195147_changes_for_v477.php+++ b/database/migrations/2018_09_05_195147_changes_for_v477.php@@ -41,21 +41,23 @@ class ChangesForV477 extends Migration*/public function down(): void{- 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');- }+ if(Schema::hasColumn('budget_limits', 'transaction_currency_id')) {+ 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']);- }- );- } 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.');+ $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.');+ }}}@@ -66,17 +68,19 @@ class ChangesForV477 extends Migration*/public function up(): void{- 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.');+ if(!Schema::hasColumn('budget_limits', 'transaction_currency_id')) {+ 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 f4dd7193b4..989d7aaf83 100644--- a/database/migrations/2018_11_06_172532_changes_for_v479.php+++ b/database/migrations/2018_11_06_172532_changes_for_v479.php@@ -41,16 +41,18 @@ class ChangesForV479 extends Migration*/public function down(): void{- 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.');+ if(Schema::hasColumn('transaction_currencies', '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.');+ }}}@@ -61,16 +63,18 @@ class ChangesForV479 extends Migration*/public function up(): void{- 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.');+ if(!Schema::hasColumn('transaction_currencies', 'enabled')) {+ 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_03_11_223700_fix_ldap_configuration.php b/database/migrations/2019_03_11_223700_fix_ldap_configuration.phpindex 39e69a16dd..f098b8ba6e 100644--- a/database/migrations/2019_03_11_223700_fix_ldap_configuration.php+++ b/database/migrations/2019_03_11_223700_fix_ldap_configuration.php@@ -41,16 +41,18 @@ class FixLdapConfiguration extends Migration*/public function down(): void{- 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.');+ if(Schema::hasColumn('users', '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.');+ }}}@@ -65,16 +67,18 @@ 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.*/- 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.');+ if(!Schema::hasColumn('users', 'objectguid')) {+ 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 ae6a8099b7..bad696d61f 100644--- a/database/migrations/2019_03_22_183214_changes_for_v480.php+++ b/database/migrations/2019_03_22_183214_changes_for_v480.php@@ -40,65 +40,74 @@ class ChangesForV480 extends Migration*/public function down(): void{- 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')) {+ // remove group ID+ if(Schema::hasColumn('transaction_journals', 'transaction_group_id')) {+ 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->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.');+ $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.');}}- 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.');- }- }- );- } 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.');+ );+ } 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) {- 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.');+ // remove 'stop processing' column+ if(Schema::hasColumn('rule_groups', 'stop_processing')) {+ 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.');+ );+ } 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.');+ // remove 'mfa_secret' column+ if(Schema::hasColumn('users', 'mfa_secret')) {+ 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.');+ );+ } 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.');+ }}}@@ -109,52 +118,63 @@ class ChangesForV480 extends Migration*/public function up(): void{- try {- Schema::table(- 'transaction_journals',- static function (Blueprint $table) {- $table->integer('transaction_currency_id', false, true)->nullable()->change();+ // add currency_id+ if(!Schema::hasColumn('transaction_journals', 'transaction_group_id')) {+ 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"- 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.'- );+ // 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.');+ );+ } 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.');++ // add 'stop processing' column+ if(!Schema::hasColumn('rule_groups', 'stop_processing')) {+ 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.');++ // add 'mfa_secret' column+ if(!Schema::hasColumn('users', 'mfa_secret')) {+ 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/2019_12_28_191351_make_locations_table.php b/database/migrations/2019_12_28_191351_make_locations_table.phpindex 10727d28ea..22b80e8c36 100644--- a/database/migrations/2019_12_28_191351_make_locations_table.php+++ b/database/migrations/2019_12_28_191351_make_locations_table.php@@ -51,25 +51,27 @@ class MakeLocationsTable extends Migration*/public function up(): void{- try {- Schema::create(- 'locations',- static function (Blueprint $table) {- $table->bigIncrements('id');- $table->timestamps();- $table->softDeletes();+ if (!Schema::hasTable('locations')) {+ try {+ Schema::create(+ 'locations',+ static function (Blueprint $table) {+ $table->bigIncrements('id');+ $table->timestamps();+ $table->softDeletes();- $table->integer('locatable_id', false, true);- $table->string('locatable_type', 255);+ $table->integer('locatable_id', false, true);+ $table->string('locatable_type', 255);- $table->decimal('latitude', 12, 8)->nullable();- $table->decimal('longitude', 12, 8)->nullable();- $table->smallInteger('zoom_level', false, true)->nullable();- }- );- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "locations": %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.');+ $table->decimal('latitude', 12, 8)->nullable();+ $table->decimal('longitude', 12, 8)->nullable();+ $table->smallInteger('zoom_level', false, true)->nullable();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "locations": %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/2020_06_30_202620_changes_for_v530a.php b/database/migrations/2020_06_30_202620_changes_for_v530a.phpindex eee512a65c..31e3a30ce0 100644--- a/database/migrations/2020_06_30_202620_changes_for_v530a.php+++ b/database/migrations/2020_06_30_202620_changes_for_v530a.php@@ -42,16 +42,18 @@ class ChangesForV530a extends Migration*/public function down(): void{- 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.');+ if(Schema::hasColumn('bills', '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.');+ }}}@@ -62,16 +64,18 @@ class ChangesForV530a extends Migration*/public function up(): void{- 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.');+ if(!Schema::hasColumn('bills', 'order')) {+ 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 8d3d78eb92..7ecd702f96 100644--- a/database/migrations/2020_07_24_162820_changes_for_v540.php+++ b/database/migrations/2020_07_24_162820_changes_for_v540.php@@ -42,42 +42,47 @@ class ChangesForV540 extends Migration*/public function down(): void{- 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.');+ if(Schema::hasColumn('oauth_clients', '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.');+ }}- 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.');+ if(Schema::hasColumn('accounts', '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.');+ }}+ if(Schema::hasColumn('bills', 'end_date') && Schema::hasColumn('bills', 'extension_date')) {+ try {+ Schema::table(+ 'bills',+ static function (Blueprint $table) {+ $table->dropColumn('end_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.');+ $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.');+ }}}@@ -88,40 +93,49 @@ class ChangesForV540 extends Migration*/public function up(): void{- 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.');+ if(!Schema::hasColumn('accounts', 'order')) {+ 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.');++ if(!Schema::hasColumn('oauth_clients', 'provider')) {+ 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.');++ if(!Schema::hasColumn('bills', 'end_date') && !Schema::hasColumn('bills', 'extension_date')) {+ 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:try {Schema::table(diff --git a/database/migrations/2020_11_12_070604_changes_for_v550.php b/database/migrations/2020_11_12_070604_changes_for_v550.phpindex 02e894715c..9c4699da6c 100644--- a/database/migrations/2020_11_12_070604_changes_for_v550.php+++ b/database/migrations/2020_11_12_070604_changes_for_v550.php@@ -43,57 +43,65 @@ class ChangesForV550 extends Migration// recreate jobs table.Schema::dropIfExists('jobs');- try {- Schema::create(- 'jobs',- static function (Blueprint $table) {- // straight from Laravel (this is the OLD table)- $table->bigIncrements('id');- $table->string('queue');- $table->longText('payload');- $table->tinyInteger('attempts')->unsigned();- $table->tinyInteger('reserved')->unsigned();- $table->unsignedInteger('reserved_at')->nullable();- $table->unsignedInteger('available_at');- $table->unsignedInteger('created_at');- $table->index(['queue', 'reserved', 'reserved_at']);- }- );- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "jobs": %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.');+ if (!Schema::hasTable('jobs')) {+ try {+ Schema::create(+ 'jobs',+ static function (Blueprint $table) {+ // straight from Laravel (this is the OLD table)+ $table->bigIncrements('id');+ $table->string('queue');+ $table->longText('payload');+ $table->tinyInteger('attempts')->unsigned();+ $table->tinyInteger('reserved')->unsigned();+ $table->unsignedInteger('reserved_at')->nullable();+ $table->unsignedInteger('available_at');+ $table->unsignedInteger('created_at');+ $table->index(['queue', 'reserved', 'reserved_at']);+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "jobs": %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.');+ }}// expand budget / transaction journal table.- 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.');+ if(Schema::hasColumn('budget_transaction_journal', '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- 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.');+ if(Schema::hasColumn('budget_limits', 'period') && Schema::hasColumn('budget_limits', '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.');+ }}++ // drop other tablesSchema::dropIfExists('webhook_attempts');Schema::dropIfExists('webhook_messages');Schema::dropIfExists('webhooks');@@ -109,63 +117,70 @@ class ChangesForV550 extends Migration// drop and recreate jobs table.Schema::dropIfExists('jobs');// this is the NEW table- try {- Schema::create(- 'jobs',- function (Blueprint $table) {- $table->bigIncrements('id');- $table->string('queue')->index();- $table->longText('payload');- $table->unsignedTinyInteger('attempts');- $table->unsignedInteger('reserved_at')->nullable();- $table->unsignedInteger('available_at');- $table->unsignedInteger('created_at');- }- );- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "jobs": %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.');+ if (!Schema::hasTable('jobs')) {+ try {+ Schema::create(+ 'jobs',+ function (Blueprint $table) {+ $table->bigIncrements('id');+ $table->string('queue')->index();+ $table->longText('payload');+ $table->unsignedTinyInteger('attempts');+ $table->unsignedInteger('reserved_at')->nullable();+ $table->unsignedInteger('available_at');+ $table->unsignedInteger('created_at');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "jobs": %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.');+ }}// drop failed jobs table.Schema::dropIfExists('failed_jobs');// create new failed_jobs table.- try {- Schema::create(- 'failed_jobs',- function (Blueprint $table) {- $table->bigIncrements('id');- $table->string('uuid')->unique();- $table->text('connection');- $table->text('queue');- $table->longText('payload');- $table->longText('exception');- $table->timestamp('failed_at')->useCurrent();- }- );- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "failed_jobs": %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.');+ if (!Schema::hasTable('failed_jobs')) {+ try {+ Schema::create(+ 'failed_jobs',+ function (Blueprint $table) {+ $table->bigIncrements('id');+ $table->string('uuid')->unique();+ $table->text('connection');+ $table->text('queue');+ $table->longText('payload');+ $table->longText('exception');+ $table->timestamp('failed_at')->useCurrent();+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "failed_jobs": %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.');+ }}// update budget / transaction journal table.- 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');+ if(!Schema::hasColumn('budget_transaction_journal', 'budget_limit_id')) {+ 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.');+ );+ } 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.+ // I swear I dropped & recreated this field 15 times already.+try {Schema::table('budget_limits',diff --git a/database/migrations/2021_03_12_061213_changes_for_v550b2.php b/database/migrations/2021_03_12_061213_changes_for_v550b2.phpindex 94a08bc4fb..41ae6e4426 100644--- a/database/migrations/2021_03_12_061213_changes_for_v550b2.php+++ b/database/migrations/2021_03_12_061213_changes_for_v550b2.php@@ -40,19 +40,21 @@ class ChangesForV550b2 extends Migration*/public function down(): void{- 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');+ if(Schema::hasColumn('recurrences_transactions', '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.');+ );+ } 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.');+ }}}@@ -64,19 +66,21 @@ class ChangesForV550b2 extends Migrationpublic function up(): void{// expand recurrence transaction table- 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');+ if(!Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {+ 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.');+ );+ } 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 763b51ca5b..c8d29df8ac 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@@ -35,16 +35,18 @@ class AddLdapColumnsToUsersTable extends Migration*/public function down(): void{- 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.');+ if(Schema::hasColumn('users', '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.');+ }}}@@ -53,16 +55,18 @@ class AddLdapColumnsToUsersTable extends Migration*/public function up(): void{- 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.');+ if(!Schema::hasColumn('users', 'domain')) {+ 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_08_28_073733_user_groups.php b/database/migrations/2021_08_28_073733_user_groups.phpindex ca3b597aa7..ce6a7a3fca 100644--- a/database/migrations/2021_08_28_073733_user_groups.php+++ b/database/migrations/2021_08_28_073733_user_groups.php@@ -60,12 +60,31 @@ class UserGroups extends Migration// remove columns from tables/** @var string $tableName */foreach ($this->tables as $tableName) {+ if (Schema::hasColumn($tableName, 'user_group_id')) {+ 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.');+ }+ }+ }++ if (Schema::hasColumn('users', 'user_group_id')) {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');}}@@ -76,21 +95,6 @@ class UserGroups extends Migration}}- try {- Schema::table(- '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::dropIfExists('group_memberships');Schema::dropIfExists('user_roles');Schema::dropIfExists('user_groups');@@ -107,59 +111,64 @@ class UserGroups extends Migration* user is a member of a user_group through a user_group_role* may have multiple roles in a group*/- try {- Schema::create(- 'user_groups',- static function (Blueprint $table) {- $table->bigIncrements('id');- $table->timestamps();- $table->softDeletes();+ if (!Schema::hasTable('user_groups')) {+ try {+ Schema::create(+ 'user_groups',+ static function (Blueprint $table) {+ $table->bigIncrements('id');+ $table->timestamps();+ $table->softDeletes();- $table->string('title', 255);- $table->unique('title');- }- );- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "user_groups": %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.');+ $table->string('title', 255);+ $table->unique('title');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "user_groups": %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(- 'user_roles',- static function (Blueprint $table) {- $table->bigIncrements('id');- $table->timestamps();- $table->softDeletes();+ if (!Schema::hasTable('user_roles')) {+ try {+ Schema::create(+ 'user_roles',+ static function (Blueprint $table) {+ $table->bigIncrements('id');+ $table->timestamps();+ $table->softDeletes();- $table->string('title', 255);- $table->unique('title');- }- );- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "user_roles": %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.');+ $table->string('title', 255);+ $table->unique('title');+ }+ );+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "user_roles": %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.');+ }}+ if (!Schema::hasTable('group_memberships')) {+ try {+ Schema::create(+ 'group_memberships',+ static function (Blueprint $table) {+ $table->bigIncrements('id');+ $table->timestamps();+ $table->softDeletes();+ $table->integer('user_id', false, true);+ $table->bigInteger('user_group_id', false, true);+ $table->bigInteger('user_role_id', false, true);- try {- Schema::create(- 'group_memberships',- static function (Blueprint $table) {- $table->bigIncrements('id');- $table->timestamps();- $table->softDeletes();- $table->integer('user_id', false, true);- $table->bigInteger('user_group_id', false, true);- $table->bigInteger('user_role_id', false, true);-- $table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');- $table->foreign('user_group_id')->references('id')->on('user_groups')->onUpdate('cascade')->onDelete('cascade');- $table->foreign('user_role_id')->references('id')->on('user_roles')->onUpdate('cascade')->onDelete('cascade');- $table->unique(['user_id', 'user_group_id', 'user_role_id']);- }- );- } catch (QueryException $e) {- Log::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.');+ $table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');+ $table->foreign('user_group_id')->references('id')->on('user_groups')->onUpdate('cascade')->onDelete('cascade');+ $table->foreign('user_role_id')->references('id')->on('user_roles')->onUpdate('cascade')->onDelete('cascade');+ $table->unique(['user_id', 'user_group_id', 'user_role_id']);+ }+ );+ } catch (QueryException $e) {+ Log::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.');+ }}try {Schema::table(@@ -167,7 +176,9 @@ class UserGroups extends Migrationfunction (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');+ $table->foreign('user_group_id', 'type_user_group_id')->references('id')->on('user_groups')->onDelete('set null')->onUpdate(+ 'cascade'+ );}});@@ -175,7 +186,6 @@ class UserGroups extends MigrationLog::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) {diff --git a/database/migrations/2022_09_18_123911_create_notifications_table.php b/database/migrations/2022_09_18_123911_create_notifications_table.phpindex aca0789a0a..af4becdadb 100644--- a/database/migrations/2022_09_18_123911_create_notifications_table.php+++ b/database/migrations/2022_09_18_123911_create_notifications_table.php@@ -36,18 +36,20 @@ return new class () extends Migration {*/public function up(): void{- try {- Schema::create('notifications', function (Blueprint $table) {- $table->uuid('id')->primary();- $table->string('type');- $table->morphs('notifiable');- $table->text('data');- $table->timestamp('read_at')->nullable();- $table->timestamps();- });- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "notifications": %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.');+ if (!Schema::hasTable('notifications')) {+ try {+ Schema::create('notifications', function (Blueprint $table) {+ $table->uuid('id')->primary();+ $table->string('type');+ $table->morphs('notifiable');+ $table->text('data');+ $table->timestamp('read_at')->nullable();+ $table->timestamps();+ });+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "notifications": %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/2022_10_01_074908_invited_users.php b/database/migrations/2022_10_01_074908_invited_users.phpindex 777a927ec2..884ce92476 100644--- a/database/migrations/2022_10_01_074908_invited_users.php+++ b/database/migrations/2022_10_01_074908_invited_users.php@@ -36,20 +36,22 @@ return new class () extends Migration {*/public function up(): void{- try {- Schema::create('invited_users', function (Blueprint $table) {- $table->id();- $table->timestamps();- $table->integer('user_id', false, true);- $table->string('email', 255);- $table->string('invite_code', 64);- $table->dateTime('expires');- $table->boolean('redeemed');- $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');- });- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "invited_users": %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.');+ if (!Schema::hasTable('invited_users')) {+ try {+ Schema::create('invited_users', function (Blueprint $table) {+ $table->id();+ $table->timestamps();+ $table->integer('user_id', false, true);+ $table->string('email', 255);+ $table->string('invite_code', 64);+ $table->dateTime('expires');+ $table->boolean('redeemed');+ $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');+ });+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "invited_users": %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/2022_10_01_210238_audit_log_entries.php b/database/migrations/2022_10_01_210238_audit_log_entries.phpindex 296e283a20..a4c9e82163 100644--- a/database/migrations/2022_10_01_210238_audit_log_entries.php+++ b/database/migrations/2022_10_01_210238_audit_log_entries.php@@ -36,25 +36,27 @@ return new class () extends Migration {*/public function up(): void{- try {- Schema::create('audit_log_entries', function (Blueprint $table) {- $table->id();- $table->timestamps();- $table->softDeletes();+ if (!Schema::hasTable('audit_log_entries')) {+ try {+ Schema::create('audit_log_entries', function (Blueprint $table) {+ $table->id();+ $table->timestamps();+ $table->softDeletes();- $table->integer('auditable_id', false, true);- $table->string('auditable_type');+ $table->integer('auditable_id', false, true);+ $table->string('auditable_type');- $table->integer('changer_id', false, true);- $table->string('changer_type');+ $table->integer('changer_id', false, true);+ $table->string('changer_type');- $table->string('action', 255);- $table->text('before')->nullable();- $table->text('after')->nullable();- });- } catch (QueryException $e) {- Log::error(sprintf('Could not create table "audit_log_entries": %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.');+ $table->string('action', 255);+ $table->text('before')->nullable();+ $table->text('after')->nullable();+ });+ } catch (QueryException $e) {+ Log::error(sprintf('Could not create table "audit_log_entries": %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.');+ }}}