Merge pull request #7353 from firefly-iii/migration-checks

Catch all possible migration errors
This commit is contained in:
James Cole 2023-04-10 08:29:49 +02:00 committed by GitHub
commit b91e019416
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
34 changed files with 1213 additions and 1035 deletions

View File

@ -1,5 +1,7 @@
<?php <?php
declare(strict_types=1);
namespace FireflyIII\Console\Commands; namespace FireflyIII\Console\Commands;
use FireflyIII\Exceptions\FireflyException; use FireflyIII\Exceptions\FireflyException;
@ -9,7 +11,7 @@ use Illuminate\Support\Facades\Log;
class ForceDecimalSize extends Command class ForceDecimalSize extends Command
{ {
use VerifiesAccessToken; use VerifiesAccessToken;
/** /**
* The name and signature of the console command. * The name and signature of the console command.
* *

View File

@ -52,6 +52,7 @@ use Illuminate\Support\Carbon;
* @property-read Collection<int, \FireflyIII\Models\Account> $accounts * @property-read Collection<int, \FireflyIII\Models\Account> $accounts
* @property-read int|null $accounts_count * @property-read int|null $accounts_count
* @property-read Collection<int, \FireflyIII\Models\Account> $accounts * @property-read Collection<int, \FireflyIII\Models\Account> $accounts
* @property-read Collection<int, \FireflyIII\Models\Account> $accounts
* @mixin Eloquent * @mixin Eloquent
*/ */
class UserGroup extends Model class UserGroup extends Model

15
composer.lock generated
View File

@ -4075,16 +4075,16 @@
}, },
{ {
"name": "nyholm/psr7", "name": "nyholm/psr7",
"version": "1.5.1", "version": "1.6.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/Nyholm/psr7.git", "url": "https://github.com/Nyholm/psr7.git",
"reference": "f734364e38a876a23be4d906a2a089e1315be18a" "reference": "bf4aebd170fadf5fd808c70b90535de327e81a50"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/Nyholm/psr7/zipball/f734364e38a876a23be4d906a2a089e1315be18a", "url": "https://api.github.com/repos/Nyholm/psr7/zipball/bf4aebd170fadf5fd808c70b90535de327e81a50",
"reference": "f734364e38a876a23be4d906a2a089e1315be18a", "reference": "bf4aebd170fadf5fd808c70b90535de327e81a50",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4094,6 +4094,7 @@
"psr/http-message": "^1.0" "psr/http-message": "^1.0"
}, },
"provide": { "provide": {
"php-http/message-factory-implementation": "1.0",
"psr/http-factory-implementation": "1.0", "psr/http-factory-implementation": "1.0",
"psr/http-message-implementation": "1.0" "psr/http-message-implementation": "1.0"
}, },
@ -4106,7 +4107,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.4-dev" "dev-master": "1.6-dev"
} }
}, },
"autoload": { "autoload": {
@ -4136,7 +4137,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/Nyholm/psr7/issues", "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": [ "funding": [
{ {
@ -4148,7 +4149,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2022-06-22T07:13:36+00:00" "time": "2023-04-09T08:34:27+00:00"
}, },
{ {
"name": "paragonie/constant_time_encoding", "name": "paragonie/constant_time_encoding",

View File

@ -45,6 +45,7 @@ class FixNullables extends Migration
*/ */
public function up(): void public function up(): void
{ {
if (!Schema::hasColumn('rule_groups', 'description')) {
try { try {
Schema::table( Schema::table(
'rule_groups', 'rule_groups',
@ -56,7 +57,9 @@ class FixNullables extends Migration
Log::error(sprintf('Could not update table: %s', $e->getMessage())); 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.'); 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 { try {
Schema::table( Schema::table(
'rules', 'rules',
@ -69,4 +72,5 @@ class FixNullables extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -38,6 +38,7 @@ class ExpandTransactionsTable extends Migration
*/ */
public function down(): void public function down(): void
{ {
if (Schema::hasColumn('transactions', 'identifier')) {
try { try {
Schema::table( Schema::table(
'transactions', 'transactions',
@ -46,10 +47,11 @@ class ExpandTransactionsTable extends Migration
} }
); );
} catch (QueryException|ColumnDoesNotExist $e) { } catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not drop column "extended_status": %s', $e->getMessage())); 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.'); Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
/** /**
* Run the migrations. * Run the migrations.
@ -57,6 +59,7 @@ class ExpandTransactionsTable extends Migration
*/ */
public function up(): void public function up(): void
{ {
if (!Schema::hasColumn('transactions', 'identifier')) {
try { try {
Schema::table( Schema::table(
'transactions', 'transactions',
@ -69,4 +72,5 @@ class ExpandTransactionsTable extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -46,6 +46,7 @@ class ChangesForV410 extends Migration
*/ */
public function up(): void public function up(): void
{ {
if(!Schema::hasTable('notes')) {
try { try {
Schema::create( Schema::create(
'notes', 'notes',
@ -64,4 +65,5 @@ class ChangesForV410 extends Migration
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'); Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
} }
} }
}
} }

View File

@ -37,6 +37,7 @@ class ChangesForV420 extends Migration
*/ */
public function down(): void public function down(): void
{ {
if (Schema::hasColumn('journal_meta', 'deleted_at')) {
try { try {
Schema::table( Schema::table(
'journal_meta', 'journal_meta',
@ -49,6 +50,7 @@ class ChangesForV420 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
/** /**
* Run the migrations. * Run the migrations.
@ -56,6 +58,7 @@ class ChangesForV420 extends Migration
*/ */
public function up(): void public function up(): void
{ {
if (!Schema::hasColumn('journal_meta', 'deleted_at')) {
try { try {
Schema::table( Schema::table(
'journal_meta', 'journal_meta',
@ -68,4 +71,5 @@ class ChangesForV420 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -46,6 +46,7 @@ class ChangesForV430 extends Migration
*/ */
public function up(): void public function up(): void
{ {
if (!Schema::hasTable('available_budgets')) {
try { try {
Schema::create( Schema::create(
'available_budgets', 'available_budgets',
@ -68,4 +69,5 @@ class ChangesForV430 extends Migration
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'); Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
} }
} }
}
} }

View File

@ -39,6 +39,7 @@ class ChangesForV431 extends Migration
public function down(): void public function down(): void
{ {
// reinstate "repeats" and "repeat_freq". // reinstate "repeats" and "repeat_freq".
if (!Schema::hasColumn('budget_limits', 'repeat_freq')) {
try { try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
@ -50,6 +51,8 @@ class ChangesForV431 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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 { try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
@ -61,8 +64,9 @@ class ChangesForV431 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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" // change field "start_date" to "startdate"
if (Schema::hasColumn('budget_limits', 'start_date') && !Schema::hasColumn('budget_limits', 'startdate')) {
try { try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
@ -74,8 +78,10 @@ class ChangesForV431 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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" // remove date field "end_date"
if (Schema::hasColumn('budget_limits', 'end_date')) {
try { try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
@ -87,7 +93,9 @@ class ChangesForV431 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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 // remove decimal places
if (Schema::hasColumn('transaction_currencies', 'decimal_places')) {
try { try {
Schema::table( Schema::table(
'transaction_currencies', 'transaction_currencies',
@ -100,6 +108,7 @@ class ChangesForV431 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
/** /**
* Run the migrations. * Run the migrations.
@ -108,6 +117,7 @@ class ChangesForV431 extends Migration
public function up(): void public function up(): void
{ {
// add decimal places to "transaction currencies". // add decimal places to "transaction currencies".
if (!Schema::hasColumn('transaction_currencies', 'decimal_places')) {
try { try {
Schema::table( Schema::table(
'transaction_currencies', 'transaction_currencies',
@ -119,8 +129,10 @@ class ChangesForV431 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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" // change field "startdate" to "start_date"
if (Schema::hasColumn('budget_limits', 'startdate') && !Schema::hasColumn('budget_limits', 'start_date')) {
try { try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
@ -132,8 +144,10 @@ class ChangesForV431 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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" // add date field "end_date" after "start_date"
if (!Schema::hasColumn('budget_limits', 'end_date')) {
try { try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
@ -145,8 +159,10 @@ class ChangesForV431 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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". // drop "repeats" and "repeat_freq".
if (Schema::hasColumn('budget_limits', 'repeats')) {
try { try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
@ -158,6 +174,8 @@ class ChangesForV431 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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 { try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
@ -170,4 +188,5 @@ class ChangesForV431 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -89,7 +89,7 @@ class ChangesForV440 extends Migration
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'); 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::hasColumn('transactions', 'transaction_currency_id')) {
try { try {
Schema::table( Schema::table(
'transactions', 'transactions',
@ -105,4 +105,5 @@ class ChangesForV440 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -39,6 +39,7 @@ class ChangesForV450 extends Migration
public function down(): void public function down(): void
{ {
// split up for sqlite compatibility // split up for sqlite compatibility
if(Schema::hasColumn('transactions', 'foreign_amount')) {
try { try {
Schema::table( Schema::table(
'transactions', 'transactions',
@ -50,6 +51,7 @@ class ChangesForV450 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
}
try { try {
Schema::table( Schema::table(
@ -65,7 +67,7 @@ class ChangesForV450 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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 { try {
Schema::table( Schema::table(
'transactions', 'transactions',
@ -78,6 +80,7 @@ class ChangesForV450 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
/** /**
* Run the migrations. * Run the migrations.
@ -86,6 +89,7 @@ class ChangesForV450 extends Migration
public function up(): void public function up(): void
{ {
// add "foreign_amount" to transactions // add "foreign_amount" to transactions
if(!Schema::hasColumn('transactions', 'foreign_amount')) {
try { try {
Schema::table( Schema::table(
'transactions', 'transactions',
@ -97,8 +101,10 @@ class ChangesForV450 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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): // add foreign transaction currency id to transactions (is nullable):
if(!Schema::hasColumn('transactions', 'foreign_currency_id')) {
try { try {
Schema::table( Schema::table(
'transactions', 'transactions',
@ -112,4 +118,5 @@ class ChangesForV450 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -39,6 +39,7 @@ class ChangesForV470a extends Migration
*/ */
public function down(): void public function down(): void
{ {
if (Schema::hasColumn('transactions', 'reconciled')) {
try { try {
Schema::table( Schema::table(
'transactions', 'transactions',
@ -51,6 +52,7 @@ class ChangesForV470a extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
/** /**
* Run the migrations. * Run the migrations.
@ -58,6 +60,7 @@ class ChangesForV470a extends Migration
*/ */
public function up(): void public function up(): void
{ {
if (!Schema::hasColumn('transactions', 'reconciled')) {
try { try {
Schema::table( Schema::table(
'transactions', 'transactions',
@ -70,4 +73,5 @@ class ChangesForV470a extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -47,6 +47,7 @@ class CreateOauthAuthCodesTable extends Migration
*/ */
public function up(): void public function up(): void
{ {
if(!Schema::hasTable('oauth_auth_codes')) {
try { try {
Schema::create( Schema::create(
'oauth_auth_codes', 'oauth_auth_codes',
@ -64,4 +65,5 @@ class CreateOauthAuthCodesTable extends Migration
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'); Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
} }
} }
}
} }

View File

@ -47,6 +47,7 @@ class CreateOauthAccessTokensTable extends Migration
*/ */
public function up(): void public function up(): void
{ {
if(!Schema::hasTable('oauth_access_tokens')) {
try { try {
Schema::create( Schema::create(
'oauth_access_tokens', 'oauth_access_tokens',
@ -66,4 +67,5 @@ class CreateOauthAccessTokensTable extends Migration
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'); Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
} }
} }
}
} }

View File

@ -47,6 +47,7 @@ class CreateOauthRefreshTokensTable extends Migration
*/ */
public function up(): void public function up(): void
{ {
if(!Schema::hasTable('oauth_refresh_tokens')) {
try { try {
Schema::create( Schema::create(
'oauth_refresh_tokens', 'oauth_refresh_tokens',
@ -62,4 +63,5 @@ class CreateOauthRefreshTokensTable extends Migration
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'); Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
} }
} }
}
} }

View File

@ -47,6 +47,7 @@ class CreateOauthClientsTable extends Migration
*/ */
public function up(): void public function up(): void
{ {
if(!Schema::hasTable('oauth_clients')) {
try { try {
Schema::create( Schema::create(
'oauth_clients', 'oauth_clients',
@ -67,4 +68,5 @@ class CreateOauthClientsTable extends Migration
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'); Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
} }
} }
}
} }

View File

@ -47,6 +47,7 @@ class CreateOauthPersonalAccessClientsTable extends Migration
*/ */
public function up(): void public function up(): void
{ {
if(!Schema::hasTable('oauth_personal_access_clients')) {
try { try {
Schema::create( Schema::create(
'oauth_personal_access_clients', 'oauth_personal_access_clients',
@ -61,4 +62,5 @@ class CreateOauthPersonalAccessClientsTable extends Migration
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'); Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
} }
} }
}
} }

View File

@ -41,6 +41,7 @@ class ChangesForV472 extends Migration
*/ */
public function down(): void public function down(): void
{ {
if(!Schema::hasColumn('attachments', 'notes')) {
try { try {
Schema::table( Schema::table(
'attachments', 'attachments',
@ -52,7 +53,9 @@ class ChangesForV472 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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 { try {
Schema::table( Schema::table(
'budgets', 'budgets',
@ -65,6 +68,7 @@ class ChangesForV472 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
/** /**
* Run the migrations. * Run the migrations.
@ -73,6 +77,7 @@ class ChangesForV472 extends Migration
*/ */
public function up(): void public function up(): void
{ {
if(Schema::hasColumn('attachments', 'notes')) {
try { try {
Schema::table( Schema::table(
'attachments', 'attachments',
@ -84,7 +89,9 @@ class ChangesForV472 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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 { try {
Schema::table( Schema::table(
'budgets', 'budgets',
@ -97,4 +104,5 @@ class ChangesForV472 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -42,6 +42,7 @@ class ChangesForV473 extends Migration
*/ */
public function down(): void public function down(): void
{ {
if(!Schema::hasColumn('bills', 'transaction_currency_id')) {
try { try {
Schema::table( Schema::table(
'bills', 'bills',
@ -57,8 +58,9 @@ class ChangesForV473 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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 { try {
Schema::table( Schema::table(
'rules', 'rules',
@ -71,6 +73,7 @@ class ChangesForV473 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
/** /**
* Run the migrations. * Run the migrations.
@ -79,6 +82,7 @@ class ChangesForV473 extends Migration
*/ */
public function up(): void public function up(): void
{ {
if(!Schema::hasColumn('bills', 'transaction_currency_id')) {
try { try {
Schema::table( Schema::table(
'bills', 'bills',
@ -91,6 +95,8 @@ class ChangesForV473 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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 { try {
Schema::table( Schema::table(
'rules', 'rules',
@ -103,4 +109,5 @@ class ChangesForV473 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -54,6 +54,7 @@ class ChangesForV475 extends Migration
*/ */
public function up(): void public function up(): void
{ {
if (!Schema::hasTable('recurrences')) {
try { try {
Schema::create( Schema::create(
'recurrences', 'recurrences',
@ -83,6 +84,8 @@ class ChangesForV475 extends Migration
Log::error(sprintf('Could not create table "recurrences": %s', $e->getMessage())); 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.'); 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 { try {
Schema::create( Schema::create(
'recurrences_transactions', 'recurrences_transactions',
@ -111,7 +114,9 @@ class ChangesForV475 extends Migration
Log::error(sprintf('Could not create table "recurrences_transactions": %s', $e->getMessage())); 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.'); 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 { try {
Schema::create( Schema::create(
'recurrences_repetitions', 'recurrences_repetitions',
@ -132,7 +137,9 @@ class ChangesForV475 extends Migration
Log::error(sprintf('Could not create table "recurrences_repetitions": %s', $e->getMessage())); 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.'); 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 { try {
Schema::create( Schema::create(
'recurrences_meta', 'recurrences_meta',
@ -152,6 +159,9 @@ class ChangesForV475 extends Migration
Log::error(sprintf('Could not create table "recurrences_meta": %s', $e->getMessage())); 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.'); 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 { try {
Schema::create( Schema::create(
'rt_meta', 'rt_meta',
@ -172,4 +182,5 @@ class ChangesForV475 extends Migration
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'); Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
} }
} }
}
} }

View File

@ -41,6 +41,7 @@ class ChangesForV477 extends Migration
*/ */
public function down(): void public function down(): void
{ {
if(Schema::hasColumn('budget_limits', 'transaction_currency_id')) {
try { try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
@ -58,6 +59,7 @@ class ChangesForV477 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
/** /**
* Run the migrations. * Run the migrations.
@ -66,6 +68,7 @@ class ChangesForV477 extends Migration
*/ */
public function up(): void public function up(): void
{ {
if(!Schema::hasColumn('budget_limits', 'transaction_currency_id')) {
try { try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
@ -79,4 +82,5 @@ class ChangesForV477 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -41,6 +41,7 @@ class ChangesForV479 extends Migration
*/ */
public function down(): void public function down(): void
{ {
if(Schema::hasColumn('transaction_currencies', 'enabled')) {
try { try {
Schema::table( Schema::table(
'transaction_currencies', 'transaction_currencies',
@ -53,6 +54,7 @@ class ChangesForV479 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
/** /**
* Run the migrations. * Run the migrations.
@ -61,6 +63,7 @@ class ChangesForV479 extends Migration
*/ */
public function up(): void public function up(): void
{ {
if(!Schema::hasColumn('transaction_currencies', 'enabled')) {
try { try {
Schema::table( Schema::table(
'transaction_currencies', 'transaction_currencies',
@ -73,4 +76,5 @@ class ChangesForV479 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -41,6 +41,7 @@ class FixLdapConfiguration extends Migration
*/ */
public function down(): void public function down(): void
{ {
if(Schema::hasColumn('users', 'objectguid')) {
try { try {
Schema::table( Schema::table(
'users', 'users',
@ -53,6 +54,7 @@ class FixLdapConfiguration extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
/** /**
* Run the migrations. * Run the migrations.
@ -65,6 +67,7 @@ class FixLdapConfiguration extends Migration
* ADLdap2 appears to require the ability to store an objectguid for LDAP users * ADLdap2 appears to require the ability to store an objectguid for LDAP users
* now. To support this, we add the column. * now. To support this, we add the column.
*/ */
if(!Schema::hasColumn('users', 'objectguid')) {
try { try {
Schema::table( Schema::table(
'users', 'users',
@ -77,4 +80,5 @@ class FixLdapConfiguration extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -40,6 +40,8 @@ class ChangesForV480 extends Migration
*/ */
public function down(): void public function down(): void
{ {
// remove group ID
if(Schema::hasColumn('transaction_journals', 'transaction_group_id')) {
try { try {
Schema::table( Schema::table(
'transaction_journals', 'transaction_journals',
@ -66,7 +68,10 @@ class ChangesForV480 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
}
// remove 'stop processing' column
if(Schema::hasColumn('rule_groups', 'stop_processing')) {
try { try {
Schema::table( Schema::table(
'rule_groups', 'rule_groups',
@ -83,7 +88,10 @@ class ChangesForV480 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
}
// remove 'mfa_secret' column
if(Schema::hasColumn('users', 'mfa_secret')) {
try { try {
Schema::table( Schema::table(
'users', 'users',
@ -101,6 +109,7 @@ class ChangesForV480 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
/** /**
* Run the migrations. * Run the migrations.
@ -109,6 +118,8 @@ class ChangesForV480 extends Migration
*/ */
public function up(): void public function up(): void
{ {
// add currency_id
if(!Schema::hasColumn('transaction_journals', 'transaction_group_id')) {
try { try {
Schema::table( Schema::table(
'transaction_journals', 'transaction_journals',
@ -134,6 +145,10 @@ class ChangesForV480 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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 { try {
Schema::table( Schema::table(
'rule_groups', 'rule_groups',
@ -145,6 +160,10 @@ class ChangesForV480 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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 { try {
Schema::table( Schema::table(
'users', 'users',
@ -157,4 +176,5 @@ class ChangesForV480 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -51,6 +51,7 @@ class MakeLocationsTable extends Migration
*/ */
public function up(): void public function up(): void
{ {
if (!Schema::hasTable('locations')) {
try { try {
Schema::create( Schema::create(
'locations', 'locations',
@ -72,4 +73,5 @@ class MakeLocationsTable extends Migration
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'); Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
} }
} }
}
} }

View File

@ -42,6 +42,7 @@ class ChangesForV530a extends Migration
*/ */
public function down(): void public function down(): void
{ {
if(Schema::hasColumn('bills', 'order')) {
try { try {
Schema::table( Schema::table(
'bills', 'bills',
@ -54,6 +55,7 @@ class ChangesForV530a extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
/** /**
* Run the migrations. * Run the migrations.
@ -62,6 +64,7 @@ class ChangesForV530a extends Migration
*/ */
public function up(): void public function up(): void
{ {
if(!Schema::hasColumn('bills', 'order')) {
try { try {
Schema::table( Schema::table(
'bills', 'bills',
@ -74,4 +77,5 @@ class ChangesForV530a extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -42,6 +42,7 @@ class ChangesForV540 extends Migration
*/ */
public function down(): void public function down(): void
{ {
if(Schema::hasColumn('oauth_clients', 'provider')) {
try { try {
Schema::table( Schema::table(
'oauth_clients', 'oauth_clients',
@ -53,7 +54,9 @@ class ChangesForV540 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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 { try {
Schema::table( Schema::table(
'accounts', 'accounts',
@ -65,7 +68,8 @@ class ChangesForV540 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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 { try {
Schema::table( Schema::table(
'bills', 'bills',
@ -80,6 +84,7 @@ class ChangesForV540 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
/** /**
* Run the migrations. * Run the migrations.
@ -88,6 +93,7 @@ class ChangesForV540 extends Migration
*/ */
public function up(): void public function up(): void
{ {
if(!Schema::hasColumn('accounts', 'order')) {
try { try {
Schema::table( Schema::table(
'accounts', 'accounts',
@ -99,6 +105,9 @@ class ChangesForV540 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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 { try {
Schema::table( Schema::table(
'oauth_clients', 'oauth_clients',
@ -110,6 +119,9 @@ class ChangesForV540 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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 { try {
Schema::table( Schema::table(
'bills', 'bills',
@ -122,6 +134,8 @@ class ChangesForV540 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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: // make column nullable:
try { try {
Schema::table( Schema::table(

View File

@ -43,6 +43,7 @@ class ChangesForV550 extends Migration
// recreate jobs table. // recreate jobs table.
Schema::dropIfExists('jobs'); Schema::dropIfExists('jobs');
if (!Schema::hasTable('jobs')) {
try { try {
Schema::create( Schema::create(
'jobs', 'jobs',
@ -63,8 +64,10 @@ class ChangesForV550 extends Migration
Log::error(sprintf('Could not create table "jobs": %s', $e->getMessage())); 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.'); 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. // expand budget / transaction journal table.
if(Schema::hasColumn('budget_transaction_journal', 'budget_limit_id')) {
try { try {
Schema::table( Schema::table(
'budget_transaction_journal', 'budget_transaction_journal',
@ -77,11 +80,13 @@ class ChangesForV550 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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. // drop failed jobs table.
Schema::dropIfExists('failed_jobs'); Schema::dropIfExists('failed_jobs');
// drop fields from budget limits // drop fields from budget limits
if(Schema::hasColumn('budget_limits', 'period') && Schema::hasColumn('budget_limits', 'generated')) {
try { try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
@ -94,6 +99,9 @@ class ChangesForV550 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
}
// drop other tables
Schema::dropIfExists('webhook_attempts'); Schema::dropIfExists('webhook_attempts');
Schema::dropIfExists('webhook_messages'); Schema::dropIfExists('webhook_messages');
Schema::dropIfExists('webhooks'); Schema::dropIfExists('webhooks');
@ -109,6 +117,7 @@ class ChangesForV550 extends Migration
// drop and recreate jobs table. // drop and recreate jobs table.
Schema::dropIfExists('jobs'); Schema::dropIfExists('jobs');
// this is the NEW table // this is the NEW table
if (!Schema::hasTable('jobs')) {
try { try {
Schema::create( Schema::create(
'jobs', 'jobs',
@ -126,10 +135,12 @@ class ChangesForV550 extends Migration
Log::error(sprintf('Could not create table "jobs": %s', $e->getMessage())); 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.'); 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. // drop failed jobs table.
Schema::dropIfExists('failed_jobs'); Schema::dropIfExists('failed_jobs');
// create new failed_jobs table. // create new failed_jobs table.
if (!Schema::hasTable('failed_jobs')) {
try { try {
Schema::create( Schema::create(
'failed_jobs', 'failed_jobs',
@ -147,8 +158,10 @@ class ChangesForV550 extends Migration
Log::error(sprintf('Could not create table "failed_jobs": %s', $e->getMessage())); 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.'); 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. // update budget / transaction journal table.
if(!Schema::hasColumn('budget_transaction_journal', 'budget_limit_id')) {
try { try {
Schema::table( Schema::table(
'budget_transaction_journal', 'budget_transaction_journal',
@ -163,9 +176,11 @@ class ChangesForV550 extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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. // 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 { try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',

View File

@ -40,6 +40,7 @@ class ChangesForV550b2 extends Migration
*/ */
public function down(): void public function down(): void
{ {
if(Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {
try { try {
Schema::table( Schema::table(
'recurrences_transactions', 'recurrences_transactions',
@ -55,6 +56,7 @@ class ChangesForV550b2 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
/** /**
* Run the migrations. * Run the migrations.
@ -64,6 +66,7 @@ class ChangesForV550b2 extends Migration
public function up(): void public function up(): void
{ {
// expand recurrence transaction table // expand recurrence transaction table
if(!Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {
try { try {
Schema::table( Schema::table(
'recurrences_transactions', 'recurrences_transactions',
@ -79,4 +82,5 @@ class ChangesForV550b2 extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -35,6 +35,7 @@ class AddLdapColumnsToUsersTable extends Migration
*/ */
public function down(): void public function down(): void
{ {
if(Schema::hasColumn('users', 'domain')) {
try { try {
Schema::table( Schema::table(
'users', 'users',
@ -47,12 +48,14 @@ class AddLdapColumnsToUsersTable extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
/** /**
* Run the migrations. * Run the migrations.
*/ */
public function up(): void public function up(): void
{ {
if(!Schema::hasColumn('users', 'domain')) {
try { try {
Schema::table( Schema::table(
'users', 'users',
@ -65,4 +68,5 @@ class AddLdapColumnsToUsersTable extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
} }
}
} }

View File

@ -60,6 +60,7 @@ class UserGroups extends Migration
// remove columns from tables // remove columns from tables
/** @var string $tableName */ /** @var string $tableName */
foreach ($this->tables as $tableName) { foreach ($this->tables as $tableName) {
if (Schema::hasColumn($tableName, 'user_group_id')) {
try { try {
Schema::table( Schema::table(
$tableName, $tableName,
@ -75,7 +76,9 @@ class UserGroups extends Migration
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'); 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 { try {
Schema::table( Schema::table(
'users', 'users',
@ -90,6 +93,7 @@ class UserGroups extends Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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('group_memberships');
Schema::dropIfExists('user_roles'); Schema::dropIfExists('user_roles');
@ -107,6 +111,7 @@ class UserGroups extends Migration
* user is a member of a user_group through a user_group_role * user is a member of a user_group through a user_group_role
* may have multiple roles in a group * may have multiple roles in a group
*/ */
if (!Schema::hasTable('user_groups')) {
try { try {
Schema::create( Schema::create(
'user_groups', 'user_groups',
@ -123,6 +128,8 @@ class UserGroups extends Migration
Log::error(sprintf('Could not create table "user_groups": %s', $e->getMessage())); 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.'); 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('user_roles')) {
try { try {
Schema::create( Schema::create(
'user_roles', 'user_roles',
@ -139,7 +146,8 @@ class UserGroups extends Migration
Log::error(sprintf('Could not create table "user_roles": %s', $e->getMessage())); 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.'); 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 { try {
Schema::create( Schema::create(
'group_memberships', 'group_memberships',
@ -161,13 +169,16 @@ class UserGroups extends Migration
Log::error(sprintf('Could not create table "group_memberships": %s', $e->getMessage())); 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.'); 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 { try {
Schema::table( Schema::table(
'users', 'users',
function (Blueprint $table) { function (Blueprint $table) {
if (!Schema::hasColumn('users', 'user_group_id')) { if (!Schema::hasColumn('users', 'user_group_id')) {
$table->bigInteger('user_group_id', false, true)->nullable(); $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 Migration
Log::error(sprintf('Could not execute query: %s', $e->getMessage())); 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.'); 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 // ADD columns from tables
/** @var string $tableName */ /** @var string $tableName */
foreach ($this->tables as $tableName) { foreach ($this->tables as $tableName) {

View File

@ -36,6 +36,7 @@ return new class () extends Migration {
*/ */
public function up(): void public function up(): void
{ {
if (!Schema::hasTable('notifications')) {
try { try {
Schema::create('notifications', function (Blueprint $table) { Schema::create('notifications', function (Blueprint $table) {
$table->uuid('id')->primary(); $table->uuid('id')->primary();
@ -50,6 +51,7 @@ return new class () extends Migration {
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'); Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
} }
} }
}
/** /**
* Reverse the migrations. * Reverse the migrations.

View File

@ -36,6 +36,7 @@ return new class () extends Migration {
*/ */
public function up(): void public function up(): void
{ {
if (!Schema::hasTable('invited_users')) {
try { try {
Schema::create('invited_users', function (Blueprint $table) { Schema::create('invited_users', function (Blueprint $table) {
$table->id(); $table->id();
@ -52,6 +53,7 @@ return new class () extends Migration {
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'); Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
} }
} }
}
/** /**
* Reverse the migrations. * Reverse the migrations.

View File

@ -36,6 +36,7 @@ return new class () extends Migration {
*/ */
public function up(): void public function up(): void
{ {
if (!Schema::hasTable('audit_log_entries')) {
try { try {
Schema::create('audit_log_entries', function (Blueprint $table) { Schema::create('audit_log_entries', function (Blueprint $table) {
$table->id(); $table->id();
@ -57,6 +58,7 @@ return new class () extends Migration {
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'); Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
} }
} }
}
/** /**
* Reverse the migrations. * Reverse the migrations.