Merge pull request #7340 from firefly-iii/catch-errors

Catch errors
This commit is contained in:
James Cole
2023-04-08 06:28:22 +02:00
committed by GitHub
53 changed files with 2367 additions and 1619 deletions

View File

@@ -379,16 +379,16 @@
}, },
{ {
"name": "friendsofphp/php-cs-fixer", "name": "friendsofphp/php-cs-fixer",
"version": "v3.15.1", "version": "v3.16.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "d48755372a113bddb99f749e34805d83f3acfe04" "reference": "d40f9436e1c448d309fa995ab9c14c5c7a96f2dc"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/d48755372a113bddb99f749e34805d83f3acfe04", "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/d40f9436e1c448d309fa995ab9c14c5c7a96f2dc",
"reference": "d48755372a113bddb99f749e34805d83f3acfe04", "reference": "d40f9436e1c448d309fa995ab9c14c5c7a96f2dc",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@@ -463,7 +463,7 @@
], ],
"support": { "support": {
"issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues",
"source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.15.1" "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.16.0"
}, },
"funding": [ "funding": [
{ {
@@ -471,7 +471,7 @@
"type": "github" "type": "github"
} }
], ],
"time": "2023-03-13T23:26:30+00:00" "time": "2023-04-02T19:30:06+00:00"
}, },
{ {
"name": "psr/cache", "name": "psr/cache",

View File

@@ -0,0 +1,72 @@
<?php
namespace FireflyIII\Console\Commands;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
class ForceMigration extends Command
{
use VerifiesAccessToken;
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'firefly-iii:force-migrations
{--user=1 : The user ID.}
{--token= : The user\'s access token.}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'This command will force-run all database migrations.';
/**
* Execute the console command.
* @throws FireflyException
*/
public function handle(): int
{
if (!$this->verifyAccessToken()) {
$this->error('Invalid access token.');
return 1;
}
$this->error('Running this command is dangerous and can cause data loss.');
$this->error('Please do not continue.');
$question = $this->confirm('Do you want to continue?');
if (true === $question) {
$user = $this->getUser();
Log::channel('audit')->info(sprintf('User #%d ("%s") forced migrations.', $user->id, $user->email));
$this->forceMigration();
return 0;
}
return 0;
}
private function forceMigration(): void
{
$this->line('Dropping "migrations" table...');
sleep(2);
Schema::dropIfExists('migrations');
$this->line('Done!');
$this->line('Re-run all migrations...');
Artisan::call('migrate', ['--seed' => true]);
sleep(2);
$this->line('');
$this->info('Done!');
$this->line('There is a good chance you just saw a lot of error messages.');
$this->line('No need to panic yet. First try to access Firefly III (again).');
$this->line('The issue, whatever it was, may have been solved now.');
$this->line('');
}
}

View File

@@ -22,6 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -67,9 +68,13 @@ class CreateSupportTables extends Migration
$this->createConfigurationTable(); $this->createConfigurationTable();
} }
/**
* @return void
*/
private function createAccountTypeTable(): void private function createAccountTypeTable(): void
{ {
if (!Schema::hasTable('account_types')) { if (!Schema::hasTable('account_types')) {
try {
Schema::create( Schema::create(
'account_types', 'account_types',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -81,12 +86,20 @@ class CreateSupportTables extends Migration
$table->unique(['type']); $table->unique(['type']);
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "account_types": %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.');
}
} }
} }
/**
* @return void
*/
private function createConfigurationTable(): void private function createConfigurationTable(): void
{ {
if (!Schema::hasTable('configuration')) { if (!Schema::hasTable('configuration')) {
try {
Schema::create( Schema::create(
'configuration', 'configuration',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -97,12 +110,20 @@ class CreateSupportTables extends Migration
$table->text('data'); $table->text('data');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "configuration": %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.');
}
} }
} }
/**
* @return void
*/
private function createCurrencyTable(): void private function createCurrencyTable(): void
{ {
if (!Schema::hasTable('transaction_currencies')) { if (!Schema::hasTable('transaction_currencies')) {
try {
Schema::create( Schema::create(
'transaction_currencies', 'transaction_currencies',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -117,12 +138,20 @@ class CreateSupportTables extends Migration
$table->unique(['code']); $table->unique(['code']);
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "transaction_currencies": %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.');
}
} }
} }
/**
* @return void
*/
private function createJobsTable(): void private function createJobsTable(): void
{ {
if (!Schema::hasTable('jobs')) { if (!Schema::hasTable('jobs')) {
try {
Schema::create( Schema::create(
'jobs', 'jobs',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -138,12 +167,20 @@ class CreateSupportTables extends Migration
$table->index(['queue', 'reserved', 'reserved_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.');
}
} }
} }
/**
* @return void
*/
private function createPasswordTable(): void private function createPasswordTable(): void
{ {
if (!Schema::hasTable('password_resets')) { if (!Schema::hasTable('password_resets')) {
try {
Schema::create( Schema::create(
'password_resets', 'password_resets',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -153,12 +190,20 @@ class CreateSupportTables extends Migration
$table->timestamp('created_at')->nullable(); $table->timestamp('created_at')->nullable();
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "password_resets": %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.');
}
} }
} }
/**
* @return void
*/
private function createPermissionRoleTable(): void private function createPermissionRoleTable(): void
{ {
if (!Schema::hasTable('permission_role')) { if (!Schema::hasTable('permission_role')) {
try {
Schema::create( Schema::create(
'permission_role', 'permission_role',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -171,12 +216,20 @@ class CreateSupportTables extends Migration
$table->primary(['permission_id', 'role_id']); $table->primary(['permission_id', 'role_id']);
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "permission_role": %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.');
}
} }
} }
/**
* @return void
*/
private function createPermissionsTable(): void private function createPermissionsTable(): void
{ {
if (!Schema::hasTable('permissions')) { if (!Schema::hasTable('permissions')) {
try {
Schema::create( Schema::create(
'permissions', 'permissions',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -187,12 +240,20 @@ class CreateSupportTables extends Migration
$table->string('description')->nullable(); $table->string('description')->nullable();
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "permissions": %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.');
}
} }
} }
/**
* @return void
*/
private function createRolesTable(): void private function createRolesTable(): void
{ {
if (!Schema::hasTable('roles')) { if (!Schema::hasTable('roles')) {
try {
Schema::create( Schema::create(
'roles', 'roles',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -203,12 +264,20 @@ class CreateSupportTables extends Migration
$table->string('description')->nullable(); $table->string('description')->nullable();
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "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.');
}
} }
} }
/**
* @return void
*/
private function createSessionsTable(): void private function createSessionsTable(): void
{ {
if (!Schema::hasTable('sessions')) { if (!Schema::hasTable('sessions')) {
try {
Schema::create( Schema::create(
'sessions', 'sessions',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -220,12 +289,20 @@ class CreateSupportTables extends Migration
$table->integer('last_activity'); $table->integer('last_activity');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "sessions": %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.');
}
} }
} }
/**
* @return void
*/
private function createTransactionTypeTable(): void private function createTransactionTypeTable(): void
{ {
if (!Schema::hasTable('transaction_types')) { if (!Schema::hasTable('transaction_types')) {
try {
Schema::create( Schema::create(
'transaction_types', 'transaction_types',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -238,6 +315,10 @@ class CreateSupportTables extends Migration
$table->unique(['type']); $table->unique(['type']);
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "transaction_types": %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.');
}
} }
} }
} }

View File

@@ -22,6 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -47,6 +48,7 @@ class CreateUsersTable extends Migration
public function up(): void public function up(): void
{ {
if (!Schema::hasTable('users')) { if (!Schema::hasTable('users')) {
try {
Schema::create( Schema::create(
'users', 'users',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -60,6 +62,10 @@ class CreateUsersTable extends Migration
$table->string('blocked_code', 25)->nullable(); $table->string('blocked_code', 25)->nullable();
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "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.');
}
} }
} }
} }

View File

@@ -22,6 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -41,8 +42,8 @@ class CreateMainTables extends Migration
Schema::dropIfExists('attachments'); Schema::dropIfExists('attachments');
Schema::dropIfExists('limit_repetitions'); Schema::dropIfExists('limit_repetitions');
Schema::dropIfExists('budget_limits'); Schema::dropIfExists('budget_limits');
Schema::dropIfExists('export_jobs'); Schema::dropIfExists('export_jobs'); // table is no longer created
Schema::dropIfExists('import_jobs'); Schema::dropIfExists('import_jobs'); // table is no longer created
Schema::dropIfExists('preferences'); Schema::dropIfExists('preferences');
Schema::dropIfExists('role_user'); Schema::dropIfExists('role_user');
Schema::dropIfExists('rule_actions'); Schema::dropIfExists('rule_actions');
@@ -79,7 +80,6 @@ class CreateMainTables extends Migration
$this->createBillsTable(); $this->createBillsTable();
$this->createBudgetTables(); $this->createBudgetTables();
$this->createCategoriesTable(); $this->createCategoriesTable();
$this->createExportJobsTable();
$this->createPreferencesTable(); $this->createPreferencesTable();
$this->createRoleTable(); $this->createRoleTable();
$this->createRuleTables(); $this->createRuleTables();
@@ -90,6 +90,7 @@ class CreateMainTables extends Migration
private function createAccountTables(): void private function createAccountTables(): void
{ {
if (!Schema::hasTable('accounts')) { if (!Schema::hasTable('accounts')) {
try {
Schema::create( Schema::create(
'accounts', 'accounts',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -107,9 +108,14 @@ class CreateMainTables extends Migration
$table->foreign('account_type_id')->references('id')->on('account_types')->onDelete('cascade'); $table->foreign('account_type_id')->references('id')->on('account_types')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "accounts": %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('account_meta')) { if (!Schema::hasTable('account_meta')) {
try {
Schema::create( Schema::create(
'account_meta', 'account_meta',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -121,12 +127,17 @@ class CreateMainTables extends Migration
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "account_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.');
}
} }
} }
private function createAttachmentsTable(): void private function createAttachmentsTable(): void
{ {
if (!Schema::hasTable('attachments')) { if (!Schema::hasTable('attachments')) {
try {
Schema::create( Schema::create(
'attachments', 'attachments',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -149,12 +160,17 @@ class CreateMainTables extends Migration
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "attachments": %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.');
}
} }
} }
private function createBillsTable(): void private function createBillsTable(): void
{ {
if (!Schema::hasTable('bills')) { if (!Schema::hasTable('bills')) {
try {
Schema::create( Schema::create(
'bills', 'bills',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -178,6 +194,10 @@ class CreateMainTables extends Migration
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "bills": %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.');
}
} }
} }
@@ -187,6 +207,7 @@ class CreateMainTables extends Migration
private function createBudgetTables(): void private function createBudgetTables(): void
{ {
if (!Schema::hasTable('budgets')) { if (!Schema::hasTable('budgets')) {
try {
Schema::create( Schema::create(
'budgets', 'budgets',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -200,8 +221,13 @@ class CreateMainTables extends Migration
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "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.');
}
} }
if (!Schema::hasTable('budget_limits')) { if (!Schema::hasTable('budget_limits')) {
try {
Schema::create( Schema::create(
'budget_limits', 'budget_limits',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -215,8 +241,13 @@ class CreateMainTables extends Migration
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade'); $table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "budget_limits": %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('limit_repetitions')) { if (!Schema::hasTable('limit_repetitions')) {
try {
Schema::create( Schema::create(
'limit_repetitions', 'limit_repetitions',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -229,12 +260,20 @@ class CreateMainTables extends Migration
$table->foreign('budget_limit_id')->references('id')->on('budget_limits')->onDelete('cascade'); $table->foreign('budget_limit_id')->references('id')->on('budget_limits')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "limit_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.');
}
} }
} }
/**
* @return void
*/
private function createCategoriesTable(): void private function createCategoriesTable(): void
{ {
if (!Schema::hasTable('categories')) { if (!Schema::hasTable('categories')) {
try {
Schema::create( Schema::create(
'categories', 'categories',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -249,45 +288,18 @@ class CreateMainTables extends Migration
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "categories": %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.');
}
} }
} }
private function createExportJobsTable(): void
{
if (!Schema::hasTable('export_jobs')) {
Schema::create(
'export_jobs',
static function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('user_id', false, true);
$table->string('key', 12);
$table->string('status', 255);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
}
if (!Schema::hasTable('import_jobs')) {
Schema::create(
'import_jobs',
static function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->integer('user_id')->unsigned();
$table->string('key', 12)->unique();
$table->string('file_type', 12);
$table->string('status', 45);
$table->text('configuration')->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
}
}
private function createPiggyBanksTable(): void private function createPiggyBanksTable(): void
{ {
if (!Schema::hasTable('piggy_banks')) { if (!Schema::hasTable('piggy_banks')) {
try {
Schema::create( Schema::create(
'piggy_banks', 'piggy_banks',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -305,9 +317,14 @@ class CreateMainTables extends Migration
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade'); $table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "piggy_banks": %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('piggy_bank_repetitions')) { if (!Schema::hasTable('piggy_bank_repetitions')) {
try {
Schema::create( Schema::create(
'piggy_bank_repetitions', 'piggy_bank_repetitions',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -320,12 +337,17 @@ class CreateMainTables extends Migration
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade'); $table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "piggy_bank_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.');
}
} }
} }
private function createPreferencesTable(): void private function createPreferencesTable(): void
{ {
if (!Schema::hasTable('preferences')) { if (!Schema::hasTable('preferences')) {
try {
Schema::create( Schema::create(
'preferences', 'preferences',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -338,12 +360,20 @@ class CreateMainTables extends Migration
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "preferences": %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.');
}
} }
} }
/**
* @return void
*/
private function createRoleTable(): void private function createRoleTable(): void
{ {
if (!Schema::hasTable('role_user')) { if (!Schema::hasTable('role_user')) {
try {
Schema::create( Schema::create(
'role_user', 'role_user',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -356,6 +386,10 @@ class CreateMainTables extends Migration
$table->primary(['user_id', 'role_id']); $table->primary(['user_id', 'role_id']);
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "role_user": %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.');
}
} }
} }
@@ -366,6 +400,7 @@ class CreateMainTables extends Migration
private function createRuleTables(): void private function createRuleTables(): void
{ {
if (!Schema::hasTable('rule_groups')) { if (!Schema::hasTable('rule_groups')) {
try {
Schema::create( Schema::create(
'rule_groups', 'rule_groups',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -382,6 +417,10 @@ class CreateMainTables extends Migration
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "rule_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.');
}
} }
if (!Schema::hasTable('rules')) { if (!Schema::hasTable('rules')) {
Schema::create( Schema::create(
@@ -407,6 +446,7 @@ class CreateMainTables extends Migration
); );
} }
if (!Schema::hasTable('rule_actions')) { if (!Schema::hasTable('rule_actions')) {
try {
Schema::create( Schema::create(
'rule_actions', 'rule_actions',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -425,8 +465,13 @@ class CreateMainTables extends Migration
$table->foreign('rule_id')->references('id')->on('rules')->onDelete('cascade'); $table->foreign('rule_id')->references('id')->on('rules')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "rule_actions": %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('rule_triggers')) { if (!Schema::hasTable('rule_triggers')) {
try {
Schema::create( Schema::create(
'rule_triggers', 'rule_triggers',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -445,12 +490,20 @@ class CreateMainTables extends Migration
$table->foreign('rule_id')->references('id')->on('rules')->onDelete('cascade'); $table->foreign('rule_id')->references('id')->on('rules')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "rule_triggers": %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.');
}
} }
} }
/**
* @return void
*/
private function createTagsTable(): void private function createTagsTable(): void
{ {
if (!Schema::hasTable('tags')) { if (!Schema::hasTable('tags')) {
try {
Schema::create( Schema::create(
'tags', 'tags',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -471,17 +524,20 @@ class CreateMainTables extends Migration
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "tags": %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.');
}
} }
} }
/** /**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) // cannot be helped. * @return void
* @SuppressWarnings(PHPMD.NPathComplexity) // cannot be helped
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // its exactly five
*/ */
private function createTransactionTables(): void private function createTransactionTables(): void
{ {
if (!Schema::hasTable('transaction_journals')) { if (!Schema::hasTable('transaction_journals')) {
try {
Schema::create( Schema::create(
'transaction_journals', 'transaction_journals',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -507,9 +563,14 @@ class CreateMainTables extends Migration
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade'); $table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "transaction_journals": %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('journal_meta')) { if (!Schema::hasTable('journal_meta')) {
try {
Schema::create( Schema::create(
'journal_meta', 'journal_meta',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -522,9 +583,14 @@ class CreateMainTables extends Migration
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade'); $table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "journal_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('tag_transaction_journal')) { if (!Schema::hasTable('tag_transaction_journal')) {
try {
Schema::create( Schema::create(
'tag_transaction_journal', 'tag_transaction_journal',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -538,9 +604,14 @@ class CreateMainTables extends Migration
$table->unique(['tag_id', 'transaction_journal_id']); $table->unique(['tag_id', 'transaction_journal_id']);
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "tag_transaction_journal": %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('budget_transaction_journal')) { if (!Schema::hasTable('budget_transaction_journal')) {
try {
Schema::create( Schema::create(
'budget_transaction_journal', 'budget_transaction_journal',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -551,9 +622,14 @@ class CreateMainTables extends Migration
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade'); $table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "budget_transaction_journal": %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('category_transaction_journal')) { if (!Schema::hasTable('category_transaction_journal')) {
try {
Schema::create( Schema::create(
'category_transaction_journal', 'category_transaction_journal',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -564,9 +640,14 @@ class CreateMainTables extends Migration
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade'); $table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "category_transaction_journal": %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('piggy_bank_events')) { if (!Schema::hasTable('piggy_bank_events')) {
try {
Schema::create( Schema::create(
'piggy_bank_events', 'piggy_bank_events',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -581,9 +662,14 @@ class CreateMainTables extends Migration
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('set null'); $table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('set null');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "piggy_bank_events": %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('transactions')) { if (!Schema::hasTable('transactions')) {
try {
Schema::create( Schema::create(
'transactions', 'transactions',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -599,9 +685,14 @@ class CreateMainTables extends Migration
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade'); $table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "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('budget_transaction')) { if (!Schema::hasTable('budget_transaction')) {
try {
Schema::create( Schema::create(
'budget_transaction', 'budget_transaction',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -613,9 +704,14 @@ class CreateMainTables extends Migration
$table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade'); $table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "budget_transaction": %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('category_transaction')) { if (!Schema::hasTable('category_transaction')) {
try {
Schema::create( Schema::create(
'category_transaction', 'category_transaction',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -627,6 +723,10 @@ class CreateMainTables extends Migration
$table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade'); $table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "category_transaction": %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.');
}
} }
} }
} }

View File

@@ -22,7 +22,6 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
/** /**
* Class ChangesFor3101. * Class ChangesFor3101.
@@ -36,14 +35,6 @@ class ChangesFor3101 extends Migration
*/ */
public function down(): void public function down(): void
{ {
Schema::table(
'import_jobs',
static function (Blueprint $table) {
if (Schema::hasColumn('import_jobs', 'extended_status')) {
$table->dropColumn('extended_status');
}
}
);
} }
/** /**
@@ -53,13 +44,5 @@ class ChangesFor3101 extends Migration
*/ */
public function up(): void public function up(): void
{ {
Schema::table(
'import_jobs',
static function (Blueprint $table) {
if (!Schema::hasColumn('import_jobs', 'extended_status')) {
$table->text('extended_status')->nullable();
}
}
);
} }
} }

View File

@@ -22,6 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -45,18 +46,28 @@ class FixNullables extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::table( Schema::table(
'rule_groups', 'rule_groups',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->text('description')->nullable()->change(); $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( Schema::table(
'rules', 'rules',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->text('description')->nullable()->change(); $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.');
}
} }
} }

View File

@@ -21,7 +21,9 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -36,12 +38,17 @@ class ExpandTransactionsTable extends Migration
*/ */
public function down(): void public function down(): void
{ {
try {
Schema::table( Schema::table(
'transactions', 'transactions',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn('identifier'); $table->dropColumn('identifier');
} }
); );
} catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not drop column "extended_status": %s', $e->getMessage()));
Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
/** /**
@@ -51,11 +58,16 @@ class ExpandTransactionsTable extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::table( Schema::table(
'transactions', 'transactions',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->smallInteger('identifier', false, true)->default(0); $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.');
}
} }
} }

View File

@@ -22,6 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -46,6 +47,7 @@ class ChangesForV410 extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::create( Schema::create(
'notes', 'notes',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -58,5 +60,9 @@ class ChangesForV410 extends Migration
$table->text('text')->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.');
}
} }
} }

View File

@@ -22,6 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -36,12 +37,17 @@ class ChangesForV420 extends Migration
*/ */
public function down(): void public function down(): void
{ {
try {
Schema::table( Schema::table(
'journal_meta', 'journal_meta',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropSoftDeletes(); $table->dropSoftDeletes();
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
/** /**
@@ -51,11 +57,16 @@ class ChangesForV420 extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::table( Schema::table(
'journal_meta', 'journal_meta',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->softDeletes(); $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.');
}
} }
} }

View File

@@ -22,6 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -46,6 +47,7 @@ class ChangesForV430 extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::create( Schema::create(
'available_budgets', 'available_budgets',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -62,5 +64,9 @@ class ChangesForV430 extends Migration
$table->foreign('user_id')->references('id')->on('users')->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.');
}
} }
} }

View File

@@ -21,7 +21,9 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -37,41 +39,66 @@ class ChangesForV431 extends Migration
public function down(): void public function down(): void
{ {
// reinstate "repeats" and "repeat_freq". // reinstate "repeats" and "repeat_freq".
try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->string('repeat_freq', 30)->nullable(); $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( Schema::table(
'budget_limits', 'budget_limits',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->boolean('repeats')->default(0); $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" // change field "start_date" to "startdate"
try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->renameColumn('start_date', 'startdate'); $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" // remove date field "end_date"
try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn('end_date'); $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 // remove decimal places
try {
Schema::table( Schema::table(
'transaction_currencies', 'transaction_currencies',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn('decimal_places'); $table->dropColumn('decimal_places');
} }
); );
} catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
/** /**
@@ -83,41 +110,66 @@ class ChangesForV431 extends Migration
public function up(): void public function up(): void
{ {
// add decimal places to "transaction currencies". // add decimal places to "transaction currencies".
try {
Schema::table( Schema::table(
'transaction_currencies', 'transaction_currencies',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->smallInteger('decimal_places', false, true)->default(2); $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" // change field "startdate" to "start_date"
try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->renameColumn('startdate', 'start_date'); $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" // add date field "end_date" after "start_date"
try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->date('end_date')->nullable()->after('start_date'); $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". // drop "repeats" and "repeat_freq".
try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn('repeats'); $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( Schema::table(
'budget_limits', 'budget_limits',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn('repeat_freq'); $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.');
}
} }
} }

View File

@@ -21,7 +21,9 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -36,10 +38,8 @@ class ChangesForV440 extends Migration
*/ */
public function down(): void public function down(): void
{ {
if (Schema::hasTable('currency_exchange_rates')) {
Schema::dropIfExists('currency_exchange_rates'); Schema::dropIfExists('currency_exchange_rates');
} try {
Schema::table( Schema::table(
'transactions', 'transactions',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -52,6 +52,10 @@ class ChangesForV440 extends Migration
} }
} }
); );
} 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,6 +66,7 @@ class ChangesForV440 extends Migration
public function up(): void public function up(): void
{ {
if (!Schema::hasTable('currency_exchange_rates')) { if (!Schema::hasTable('currency_exchange_rates')) {
try {
Schema::create( Schema::create(
'currency_exchange_rates', 'currency_exchange_rates',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -80,8 +85,13 @@ class ChangesForV440 extends Migration
$table->foreign('to_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade'); $table->foreign('to_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
} }
); );
} 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.');
}
} }
try {
Schema::table( Schema::table(
'transactions', 'transactions',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -91,5 +101,9 @@ class ChangesForV440 extends Migration
} }
} }
); );
} 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.');
}
} }
} }

View File

@@ -21,7 +21,9 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -37,13 +39,19 @@ class ChangesForV450 extends Migration
public function down(): void public function down(): void
{ {
// split up for sqlite compatibility // split up for sqlite compatibility
try {
Schema::table( Schema::table(
'transactions', 'transactions',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn('foreign_amount'); $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 {
Schema::table( Schema::table(
'transactions', 'transactions',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -53,13 +61,22 @@ class ChangesForV450 extends Migration
} }
} }
); );
} 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( Schema::table(
'transactions', 'transactions',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn('foreign_currency_id'); $table->dropColumn('foreign_currency_id');
} }
); );
} catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
/** /**
@@ -70,14 +87,20 @@ class ChangesForV450 extends Migration
public function up(): void public function up(): void
{ {
// add "foreign_amount" to transactions // add "foreign_amount" to transactions
try {
Schema::table( Schema::table(
'transactions', 'transactions',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->decimal('foreign_amount', 32, 12)->nullable()->after('amount'); $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): // add foreign transaction currency id to transactions (is nullable):
try {
Schema::table( Schema::table(
'transactions', 'transactions',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -85,5 +108,9 @@ class ChangesForV450 extends Migration
$table->foreign('foreign_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null'); $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.');
}
} }
} }

View File

@@ -22,6 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -49,6 +50,7 @@ class ChangesForV470 extends Migration
public function up(): void public function up(): void
{ {
if (!Schema::hasTable('link_types')) { if (!Schema::hasTable('link_types')) {
try {
Schema::create( Schema::create(
'link_types', 'link_types',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -63,9 +65,14 @@ class ChangesForV470 extends Migration
$table->unique(['name', 'outward', 'inward']); $table->unique(['name', 'outward', 'inward']);
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "link_types": %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('journal_links')) { if (!Schema::hasTable('journal_links')) {
try {
Schema::create( Schema::create(
'journal_links', 'journal_links',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -83,6 +90,10 @@ class ChangesForV470 extends Migration
$table->unique(['link_type_id', 'source_id', 'destination_id']); $table->unique(['link_type_id', 'source_id', 'destination_id']);
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "journal_links": %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.');
}
} }
} }
} }

View File

@@ -21,7 +21,9 @@
*/ */
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -37,12 +39,17 @@ class ChangesForV470a extends Migration
*/ */
public function down(): void public function down(): void
{ {
try {
Schema::table( Schema::table(
'transactions', 'transactions',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn('reconciled'); $table->dropColumn('reconciled');
} }
); );
} catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
/** /**
@@ -52,11 +59,16 @@ class ChangesForV470a extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::table( Schema::table(
'transactions', 'transactions',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->boolean('reconciled')->after('deleted_at')->default(0); $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.');
}
} }
} }

View File

@@ -23,6 +23,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -47,6 +48,7 @@ class CreateOauthAuthCodesTable extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::create( Schema::create(
'oauth_auth_codes', 'oauth_auth_codes',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -58,5 +60,9 @@ class CreateOauthAuthCodesTable extends Migration
$table->dateTime('expires_at')->nullable(); $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.');
}
} }
} }

View File

@@ -23,6 +23,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -47,6 +48,7 @@ class CreateOauthAccessTokensTable extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::create( Schema::create(
'oauth_access_tokens', 'oauth_access_tokens',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -60,5 +62,9 @@ class CreateOauthAccessTokensTable extends Migration
$table->dateTime('expires_at')->nullable(); $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.');
}
} }
} }

View File

@@ -23,6 +23,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -47,6 +48,7 @@ class CreateOauthRefreshTokensTable extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::create( Schema::create(
'oauth_refresh_tokens', 'oauth_refresh_tokens',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -56,5 +58,9 @@ class CreateOauthRefreshTokensTable extends Migration
$table->dateTime('expires_at')->nullable(); $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.');
}
} }
} }

View File

@@ -23,6 +23,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -47,6 +48,7 @@ class CreateOauthClientsTable extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::create( Schema::create(
'oauth_clients', 'oauth_clients',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -61,5 +63,9 @@ class CreateOauthClientsTable extends Migration
$table->timestamps(); $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.');
}
} }
} }

View File

@@ -23,6 +23,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -47,6 +48,7 @@ class CreateOauthPersonalAccessClientsTable extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::create( Schema::create(
'oauth_personal_access_clients', 'oauth_personal_access_clients',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -55,5 +57,9 @@ class CreateOauthPersonalAccessClientsTable extends Migration
$table->timestamps(); $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.');
}
} }
} }

View File

@@ -22,7 +22,9 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -39,18 +41,29 @@ class ChangesForV472 extends Migration
*/ */
public function down(): void public function down(): void
{ {
try {
Schema::table( Schema::table(
'attachments', 'attachments',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->text('notes')->nullable(); $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( Schema::table(
'budgets', 'budgets',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn('order'); $table->dropColumn('order');
} }
); );
} catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
/** /**
@@ -61,18 +74,28 @@ class ChangesForV472 extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::table( Schema::table(
'attachments', 'attachments',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn('notes'); $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( Schema::table(
'budgets', 'budgets',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->mediumInteger('order', false, true)->default(0); $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.');
}
} }
} }

View File

@@ -22,7 +22,9 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -40,6 +42,7 @@ class ChangesForV473 extends Migration
*/ */
public function down(): void public function down(): void
{ {
try {
Schema::table( Schema::table(
'bills', 'bills',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -50,13 +53,23 @@ class ChangesForV473 extends Migration
$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.');
}
try {
Schema::table( Schema::table(
'rules', 'rules',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn('strict'); $table->dropColumn('strict');
} }
); );
} catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
/** /**
@@ -67,6 +80,7 @@ class ChangesForV473 extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::table( Schema::table(
'bills', 'bills',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -74,11 +88,20 @@ class ChangesForV473 extends Migration
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null'); $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( Schema::table(
'rules', 'rules',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->boolean('strict')->default(true); $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.');
}
} }
} }

View File

@@ -23,7 +23,6 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
/** /**
* Class ChangesForV474. * Class ChangesForV474.
@@ -34,57 +33,11 @@ class ChangesForV474 extends Migration
{ {
/** /**
* Reverse the migrations. * Reverse the migrations.
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* *
* @return void * @return void
*/ */
public function down(): void public function down(): void
{ {
// split up for sqlite compatibility.
Schema::table(
'import_jobs',
static function (Blueprint $table) {
// cannot drop foreign keys in SQLite:
if ('sqlite' !== config('database.default')) {
$table->dropForeign('import_jobs_tag_id_foreign');
}
}
);
Schema::table(
'import_jobs',
static function (Blueprint $table) {
$table->dropColumn('provider');
}
);
Schema::table(
'import_jobs',
static function (Blueprint $table) {
$table->dropColumn('stage');
}
);
Schema::table(
'import_jobs',
static function (Blueprint $table) {
$table->dropColumn('transactions');
}
);
Schema::table(
'import_jobs',
static function (Blueprint $table) {
$table->dropColumn('errors');
}
);
Schema::table(
'import_jobs',
static function (Blueprint $table) {
$table->dropColumn('tag_id');
}
);
} }
/** /**
@@ -95,17 +48,5 @@ class ChangesForV474 extends Migration
*/ */
public function up(): void public function up(): void
{ {
Schema::table(
'import_jobs',
static function (Blueprint $table) {
$table->string('provider', 50)->after('file_type')->default('');
$table->string('stage', 50)->after('status')->default('');
$table->longText('transactions')->after('extended_status')->nullable();
$table->longText('errors')->after('transactions')->nullable();
$table->integer('tag_id', false, true)->nullable()->after('user_id');
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('set null');
}
);
} }
} }

View File

@@ -23,6 +23,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -55,6 +56,7 @@ class ChangesForV475 extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::create( Schema::create(
'recurrences', 'recurrences',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -79,7 +81,11 @@ class ChangesForV475 extends Migration
$table->foreign('transaction_type_id')->references('id')->on('transaction_types')->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( Schema::create(
'recurrences_transactions', 'recurrences_transactions',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -103,7 +109,12 @@ class ChangesForV475 extends Migration
$table->foreign('destination_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( Schema::create(
'recurrences_repetitions', 'recurrences_repetitions',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -119,7 +130,12 @@ class ChangesForV475 extends Migration
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade'); $table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "recurrences_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( Schema::create(
'recurrences_meta', 'recurrences_meta',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -134,7 +150,11 @@ class ChangesForV475 extends Migration
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade'); $table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "recurrences_meta": %s', $e->getMessage()));
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
}
try {
Schema::create( Schema::create(
'rt_meta', 'rt_meta',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -149,5 +169,9 @@ class ChangesForV475 extends Migration
$table->foreign('rt_id')->references('id')->on('recurrences_transactions')->onDelete('cascade'); $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.');
}
} }
} }

View File

@@ -22,7 +22,9 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -39,6 +41,7 @@ class ChangesForV477 extends Migration
*/ */
public function down(): void public function down(): void
{ {
try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -50,6 +53,10 @@ class ChangesForV477 extends Migration
$table->dropColumn(['transaction_currency_id']); $table->dropColumn(['transaction_currency_id']);
} }
); );
} catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
/** /**
@@ -60,6 +67,7 @@ class ChangesForV477 extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -67,5 +75,9 @@ class ChangesForV477 extends Migration
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null'); $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.');
}
} }
} }

View File

@@ -22,7 +22,9 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -37,14 +39,19 @@ class ChangesForV479 extends Migration
* *
* @return void * @return void
*/ */
public function down() public function down(): void
{ {
try {
Schema::table( Schema::table(
'transaction_currencies', 'transaction_currencies',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn(['enabled']); $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.');
}
} }
/** /**
@@ -53,13 +60,18 @@ class ChangesForV479 extends Migration
* *
* @return void * @return void
*/ */
public function up() public function up(): void
{ {
try {
Schema::table( Schema::table(
'transaction_currencies', 'transaction_currencies',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->boolean('enabled')->default(0)->after('deleted_at'); $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.');
}
} }
} }

View File

@@ -23,6 +23,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -53,6 +54,7 @@ class ChangesForV4710 extends Migration
public function up(): void public function up(): void
{ {
if (!Schema::hasTable('transaction_groups')) { if (!Schema::hasTable('transaction_groups')) {
try {
Schema::create( Schema::create(
'transaction_groups', 'transaction_groups',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -65,9 +67,14 @@ class ChangesForV4710 extends Migration
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "transaction_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.');
}
} }
if (!Schema::hasTable('group_journals')) { if (!Schema::hasTable('group_journals')) {
try {
Schema::create( Schema::create(
'group_journals', 'group_journals',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -82,6 +89,10 @@ class ChangesForV4710 extends Migration
$table->unique(['transaction_group_id', 'transaction_journal_id'], 'unique_in_group'); $table->unique(['transaction_group_id', 'transaction_journal_id'], 'unique_in_group');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "group_journals": %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.');
}
} }
} }
} }

View File

@@ -23,6 +23,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -59,18 +60,28 @@ class ChangesForV4711 extends Migration
* datetime (without a time zone) for all database engines because MySQL refuses to play * datetime (without a time zone) for all database engines because MySQL refuses to play
* nice. * nice.
*/ */
try {
Schema::table( Schema::table(
'transaction_journals', 'transaction_journals',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dateTime('date')->change(); $table->dateTime('date')->change();
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
try {
Schema::table( Schema::table(
'preferences', 'preferences',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->text('data')->nullable()->change(); $table->text('data')->nullable()->change();
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
} }

View File

@@ -22,6 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -58,11 +59,16 @@ class ChangesForV4712 extends Migration
* datetime (without a time zone) for all database engines because MySQL refuses to play * datetime (without a time zone) for all database engines because MySQL refuses to play
* nice. * nice.
*/ */
try {
Schema::table( Schema::table(
'transaction_journals', 'transaction_journals',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dateTime('date')->change(); $table->dateTime('date')->change();
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
} }

View File

@@ -21,7 +21,9 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -39,12 +41,17 @@ class FixLdapConfiguration extends Migration
*/ */
public function down(): void public function down(): void
{ {
try {
Schema::table( Schema::table(
'users', 'users',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn(['objectguid']); $table->dropColumn(['objectguid']);
} }
); );
} catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
/** /**
@@ -59,11 +66,16 @@ class FixLdapConfiguration extends Migration
* ADLdap2 appears to require the ability to store an objectguid for LDAP users * 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.
*/ */
try {
Schema::table( Schema::table(
'users', 'users',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->uuid('objectguid')->nullable()->after('id'); $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.');
}
} }
} }

View File

@@ -21,7 +21,9 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -38,30 +40,66 @@ class ChangesForV480 extends Migration
*/ */
public function down(): void public function down(): void
{ {
try {
Schema::table( Schema::table(
'transaction_journals', 'transaction_journals',
static function (Blueprint $table) { static function (Blueprint $table) {
// drop transaction_group_id + foreign key. // drop transaction_group_id + foreign key.
// cannot drop foreign keys in SQLite: // cannot drop foreign keys in SQLite:
if ('sqlite' !== config('database.default')) { if ('sqlite' !== config('database.default')) {
try {
$table->dropForeign('transaction_journals_transaction_group_id_foreign'); $table->dropForeign('transaction_journals_transaction_group_id_foreign');
} catch (QueryException $e) {
Log::error(sprintf('Could not drop foreign ID: %s', $e->getMessage()));
Log::error('If the foreign ID does not exist (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
} }
}
try {
$table->dropColumn('transaction_group_id'); $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.');
}
try {
Schema::table( Schema::table(
'rule_groups', 'rule_groups',
static function (Blueprint $table) { static function (Blueprint $table) {
try {
$table->dropColumn('stop_processing'); $table->dropColumn('stop_processing');
} catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not drop column: %s', $e->getMessage()));
Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
try {
Schema::table( Schema::table(
'users', 'users',
static function (Blueprint $table) { static function (Blueprint $table) {
try {
$table->dropColumn('mfa_secret'); $table->dropColumn('mfa_secret');
} catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not drop column: %s', $e->getMessage()));
Log::error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
/** /**
@@ -72,6 +110,7 @@ class ChangesForV480 extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::table( Schema::table(
'transaction_journals', 'transaction_journals',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -82,20 +121,41 @@ class ChangesForV480 extends Migration
->nullable()->default(null)->after('transaction_type_id'); ->nullable()->default(null)->after('transaction_type_id');
// add foreign key for "transaction_group_id" // add foreign key for "transaction_group_id"
try {
$table->foreign('transaction_group_id')->references('id')->on('transaction_groups')->onDelete('cascade'); $table->foreign('transaction_group_id')->references('id')->on('transaction_groups')->onDelete('cascade');
} catch (QueryException $e) {
Log::error(sprintf('Could not create foreign index: %s', $e->getMessage()));
Log::error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
try {
Schema::table( Schema::table(
'rule_groups', 'rule_groups',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->boolean('stop_processing')->default(false); $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( Schema::table(
'users', 'users',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->string('mfa_secret', 50)->nullable(); $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.');
}
} }
} }

View File

@@ -23,6 +23,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -38,7 +39,7 @@ class MakeLocationsTable extends Migration
* *
* @return void * @return void
*/ */
public function down() public function down(): void
{ {
Schema::dropIfExists('locations'); Schema::dropIfExists('locations');
} }
@@ -48,8 +49,9 @@ class MakeLocationsTable extends Migration
* *
* @return void * @return void
*/ */
public function up() public function up(): void
{ {
try {
Schema::create( Schema::create(
'locations', 'locations',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -65,5 +67,9 @@ class MakeLocationsTable extends Migration
$table->smallInteger('zoom_level', false, true)->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.');
}
} }
} }

View File

@@ -22,6 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -50,6 +51,7 @@ class ChangesForV520 extends Migration
public function up(): void public function up(): void
{ {
if (!Schema::hasTable('auto_budgets')) { if (!Schema::hasTable('auto_budgets')) {
try {
Schema::create( Schema::create(
'auto_budgets', 'auto_budgets',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -66,24 +68,10 @@ class ChangesForV520 extends Migration
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade'); $table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
} }
); );
} } catch (QueryException $e) {
Log::error(sprintf('Could not create table "auto_budgets": %s', $e->getMessage()));
if (!Schema::hasTable('telemetry')) { Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
Schema::create( }
'telemetry',
static function (Blueprint $table) {
$table->increments('id');
$table->timestamps();
$table->dateTime('submitted')->nullable();
$table->integer('user_id', false, true)->nullable();
$table->string('installation_id', 50);
$table->string('type', 25);
$table->string('key', 50);
$table->text('value');
$table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
}
);
} }
} }
} }

View File

@@ -23,6 +23,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
/** /**
@@ -51,6 +52,7 @@ class ChangesForV530 extends Migration
public function up(): void public function up(): void
{ {
if (!Schema::hasTable('object_groups')) { if (!Schema::hasTable('object_groups')) {
try {
Schema::create( Schema::create(
'object_groups', 'object_groups',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -63,8 +65,14 @@ class ChangesForV530 extends Migration
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade'); $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "object_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.');
} }
}
if (!Schema::hasTable('object_groupables')) { if (!Schema::hasTable('object_groupables')) {
try {
Schema::create( Schema::create(
'object_groupables', 'object_groupables',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -73,6 +81,10 @@ class ChangesForV530 extends Migration
$table->string('object_groupable_type', 255); $table->string('object_groupable_type', 255);
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "object_groupables": %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.');
}
} }
} }
} }

View File

@@ -22,7 +22,9 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -40,12 +42,17 @@ class ChangesForV530a extends Migration
*/ */
public function down(): void public function down(): void
{ {
try {
Schema::table( Schema::table(
'bills', 'bills',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn('order'); $table->dropColumn('order');
} }
); );
} catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
/** /**
@@ -55,11 +62,16 @@ class ChangesForV530a extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::table( Schema::table(
'bills', 'bills',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->integer('order', false, true)->default(0); $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.');
}
} }
} }

View File

@@ -22,7 +22,9 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -40,27 +42,43 @@ class ChangesForV540 extends Migration
*/ */
public function down(): void public function down(): void
{ {
try {
Schema::table( Schema::table(
'oauth_clients', 'oauth_clients',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn('provider'); $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( Schema::table(
'accounts', 'accounts',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn('order'); $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.');
}
try {
Schema::table( Schema::table(
'bills', 'bills',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->dropColumn('end_date'); $table->dropColumn('end_date');
$table->dropColumn('extension_date'); $table->dropColumn('extension_date');
} }
); );
} catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
/** /**
@@ -70,18 +88,29 @@ class ChangesForV540 extends Migration
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::table( Schema::table(
'accounts', 'accounts',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->integer('order', false, true)->default(0); $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( Schema::table(
'oauth_clients', 'oauth_clients',
static function (Blueprint $table) { static function (Blueprint $table) {
$table->string('provider')->nullable(); $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( Schema::table(
'bills', 'bills',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -89,12 +118,21 @@ class ChangesForV540 extends Migration
$table->date('extension_date')->nullable()->after('end_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: // make column nullable:
try {
Schema::table( Schema::table(
'oauth_clients', 'oauth_clients',
function (Blueprint $table) { function (Blueprint $table) {
$table->string('secret', 100)->nullable()->change(); $table->string('secret', 100)->nullable()->change();
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
} }

View File

@@ -22,7 +22,9 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -36,10 +38,12 @@ class ChangesForV550 extends Migration
* *
* @return void * @return void
*/ */
public function down() public function down(): void
{ {
// recreate jobs table. // recreate jobs table.
Schema::dropIfExists('jobs'); Schema::dropIfExists('jobs');
try {
Schema::create( Schema::create(
'jobs', 'jobs',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -55,8 +59,13 @@ class ChangesForV550 extends Migration
$table->index(['queue', 'reserved', 'reserved_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. // expand budget / transaction journal table.
try {
Schema::table( Schema::table(
'budget_transaction_journal', 'budget_transaction_journal',
function (Blueprint $table) { function (Blueprint $table) {
@@ -64,11 +73,16 @@ class ChangesForV550 extends Migration
$table->dropColumn('budget_limit_id'); $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. // drop failed jobs table.
Schema::dropIfExists('failed_jobs'); Schema::dropIfExists('failed_jobs');
// drop fields from budget limits // drop fields from budget limits
try {
Schema::table( Schema::table(
'budget_limits', 'budget_limits',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -76,6 +90,10 @@ class ChangesForV550 extends Migration
$table->dropColumn('generated'); $table->dropColumn('generated');
} }
); );
} catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
Schema::dropIfExists('webhook_attempts'); Schema::dropIfExists('webhook_attempts');
Schema::dropIfExists('webhook_messages'); Schema::dropIfExists('webhook_messages');
Schema::dropIfExists('webhooks'); Schema::dropIfExists('webhooks');
@@ -86,11 +104,12 @@ class ChangesForV550 extends Migration
* *
* @return void * @return void
*/ */
public function up() public function up(): void
{ {
// 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
try {
Schema::create( Schema::create(
'jobs', 'jobs',
function (Blueprint $table) { function (Blueprint $table) {
@@ -103,10 +122,15 @@ class ChangesForV550 extends Migration
$table->unsignedInteger('created_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. // drop failed jobs table.
Schema::dropIfExists('failed_jobs'); Schema::dropIfExists('failed_jobs');
// create new failed_jobs table. // create new failed_jobs table.
try {
Schema::create( Schema::create(
'failed_jobs', 'failed_jobs',
function (Blueprint $table) { function (Blueprint $table) {
@@ -119,8 +143,13 @@ class ChangesForV550 extends Migration
$table->timestamp('failed_at')->useCurrent(); $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. // update budget / transaction journal table.
try {
Schema::table( Schema::table(
'budget_transaction_journal', 'budget_transaction_journal',
function (Blueprint $table) { function (Blueprint $table) {
@@ -130,9 +159,14 @@ class ChangesForV550 extends Migration
} }
} }
); );
} 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. // 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( Schema::table(
'budget_limits', 'budget_limits',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -144,9 +178,14 @@ class ChangesForV550 extends Migration
} }
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
// new webhooks table // new webhooks table
if (!Schema::hasTable('webhooks')) { if (!Schema::hasTable('webhooks')) {
try {
Schema::create( Schema::create(
'webhooks', 'webhooks',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -165,10 +204,15 @@ class ChangesForV550 extends Migration
$table->unique(['user_id', 'title']); $table->unique(['user_id', 'title']);
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "webhooks": %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.');
}
} }
// new webhook_messages table // new webhook_messages table
if (!Schema::hasTable('webhook_messages')) { if (!Schema::hasTable('webhook_messages')) {
try {
Schema::create( Schema::create(
'webhook_messages', 'webhook_messages',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -185,9 +229,14 @@ class ChangesForV550 extends Migration
$table->foreign('webhook_id')->references('id')->on('webhooks')->onDelete('cascade'); $table->foreign('webhook_id')->references('id')->on('webhooks')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "webhook_messages": %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('webhook_attempts')) { if (!Schema::hasTable('webhook_attempts')) {
try {
Schema::create( Schema::create(
'webhook_attempts', 'webhook_attempts',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -203,6 +252,10 @@ class ChangesForV550 extends Migration
$table->foreign('webhook_message_id')->references('id')->on('webhook_messages')->onDelete('cascade'); $table->foreign('webhook_message_id')->references('id')->on('webhook_messages')->onDelete('cascade');
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "webhook_attempts": %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.');
}
} }
} }
} }

View File

@@ -22,7 +22,9 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -38,6 +40,7 @@ class ChangesForV550b2 extends Migration
*/ */
public function down(): void public function down(): void
{ {
try {
Schema::table( Schema::table(
'recurrences_transactions', 'recurrences_transactions',
function (Blueprint $table) { function (Blueprint $table) {
@@ -47,6 +50,10 @@ class ChangesForV550b2 extends Migration
} }
} }
); );
} catch (QueryException|ColumnDoesNotExist $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
/** /**
@@ -57,6 +64,7 @@ class ChangesForV550b2 extends Migration
public function up(): void public function up(): void
{ {
// expand recurrence transaction table // expand recurrence transaction table
try {
Schema::table( Schema::table(
'recurrences_transactions', 'recurrences_transactions',
function (Blueprint $table) { function (Blueprint $table) {
@@ -66,5 +74,9 @@ class ChangesForV550b2 extends Migration
} }
} }
); );
} 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.');
}
} }
} }

View File

@@ -22,7 +22,9 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -31,26 +33,36 @@ class AddLdapColumnsToUsersTable extends Migration
/** /**
* Reverse the migrations. * Reverse the migrations.
*/ */
public function down() public function down(): void
{ {
try {
Schema::table( Schema::table(
'users', 'users',
function (Blueprint $table) { function (Blueprint $table) {
$table->dropColumn(['domain']); $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.');
}
} }
/** /**
* Run the migrations. * Run the migrations.
*/ */
public function up() public function up(): void
{ {
try {
Schema::table( Schema::table(
'users', 'users',
function (Blueprint $table) { function (Blueprint $table) {
$table->string('domain')->nullable(); $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.');
}
} }
} }

View File

@@ -23,6 +23,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -36,7 +37,7 @@ class ExtendCurrencyInfo extends Migration
* *
* @return void * @return void
*/ */
public function down() public function down(): void
{ {
// //
} }
@@ -46,8 +47,9 @@ class ExtendCurrencyInfo extends Migration
* *
* @return void * @return void
*/ */
public function up() public function up(): void
{ {
try {
Schema::table( Schema::table(
'transaction_currencies', 'transaction_currencies',
function (Blueprint $table) { function (Blueprint $table) {
@@ -55,5 +57,9 @@ class ExtendCurrencyInfo extends Migration
$table->string('symbol', 51)->change(); $table->string('symbol', 51)->change();
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
} }

View File

@@ -35,7 +35,7 @@ class DropTeleTable extends Migration
* *
* @return void * @return void
*/ */
public function down() public function down(): void
{ {
Schema::dropIfExists('telemetry'); Schema::dropIfExists('telemetry');
} }
@@ -45,7 +45,7 @@ class DropTeleTable extends Migration
* *
* @return void * @return void
*/ */
public function up() public function up(): void
{ {
Schema::dropIfExists('telemetry'); Schema::dropIfExists('telemetry');
} }

View File

@@ -22,7 +22,9 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -53,11 +55,12 @@ class UserGroups extends Migration
* *
* @return void * @return void
*/ */
public function down() public function down(): void
{ {
// remove columns from tables // remove columns from tables
/** @var string $tableName */ /** @var string $tableName */
foreach ($this->tables as $tableName) { foreach ($this->tables as $tableName) {
try {
Schema::table( Schema::table(
$tableName, $tableName,
function (Blueprint $table) use ($tableName) { function (Blueprint $table) use ($tableName) {
@@ -67,8 +70,13 @@ class UserGroups extends Migration
} }
} }
); );
} 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( Schema::table(
'users', 'users',
function (Blueprint $table) { function (Blueprint $table) {
@@ -78,6 +86,10 @@ class UserGroups extends Migration
} }
} }
); );
} 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('group_memberships');
Schema::dropIfExists('user_roles'); Schema::dropIfExists('user_roles');
@@ -89,12 +101,13 @@ class UserGroups extends Migration
* *
* @return void * @return void
*/ */
public function up() public function up(): void
{ {
/* /*
* 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
*/ */
try {
Schema::create( Schema::create(
'user_groups', 'user_groups',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -106,7 +119,11 @@ class UserGroups extends Migration
$table->unique('title'); $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( Schema::create(
'user_roles', 'user_roles',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -118,7 +135,12 @@ class UserGroups extends Migration
$table->unique('title'); $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.');
}
try {
Schema::create( Schema::create(
'group_memberships', 'group_memberships',
static function (Blueprint $table) { static function (Blueprint $table) {
@@ -135,6 +157,11 @@ class UserGroups extends Migration
$table->unique(['user_id', 'user_group_id', 'user_role_id']); $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( Schema::table(
'users', 'users',
function (Blueprint $table) { function (Blueprint $table) {
@@ -144,21 +171,30 @@ class UserGroups extends Migration
} }
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
// ADD columns from tables // ADD columns from tables
/** @var string $tableName */ /** @var string $tableName */
foreach ($this->tables as $tableName) { foreach ($this->tables as $tableName) {
try {
Schema::table( Schema::table(
$tableName, $tableName,
function (Blueprint $table) use ($tableName) { function (Blueprint $table) use ($tableName) {
if (!Schema::hasColumn($tableName, 'user_group_id')) { if (!Schema::hasColumn($tableName, 'user_group_id')) {
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id'); $table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
$table->foreign('user_group_id', sprintf('%s_to_ugi', $tableName))->references('id')->on('user_groups')->onDelete('set null')->onUpdate( $table->foreign('user_group_id', sprintf('%s_to_ugi', $tableName))->references('id')->on('user_groups')->onDelete(
'cascade' 'set null'
); )->onUpdate('cascade');
} }
} }
); );
} catch (QueryException $e) {
Log::error(sprintf('Could not execute query: %s', $e->getMessage()));
Log::error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
} }
} }
} }

View File

@@ -23,6 +23,7 @@
declare(strict_types=1); declare(strict_types=1);
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
@@ -36,7 +37,7 @@ class CreateLocalPersonalAccessTokensTable extends Migration
* *
* @return void * @return void
*/ */
public function down() public function down(): void
{ {
Schema::dropIfExists('personal_access_tokens'); Schema::dropIfExists('personal_access_tokens');
} }
@@ -46,9 +47,10 @@ class CreateLocalPersonalAccessTokensTable extends Migration
* *
* @return void * @return void
*/ */
public function up() public function up(): void
{ {
if (!Schema::hasTable('personal_access_tokens')) { if (!Schema::hasTable('personal_access_tokens')) {
try {
Schema::create('personal_access_tokens', function (Blueprint $table) { Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->bigIncrements('id'); $table->bigIncrements('id');
$table->morphs('tokenable'); $table->morphs('tokenable');
@@ -58,6 +60,10 @@ class CreateLocalPersonalAccessTokensTable extends Migration
$table->timestamp('last_used_at')->nullable(); $table->timestamp('last_used_at')->nullable();
$table->timestamps(); $table->timestamps();
}); });
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "personal_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.');
}
} }
} }
} }

View File

@@ -22,6 +22,7 @@
declare(strict_types=1); declare(strict_types=1);
use Doctrine\DBAL\Schema\Exception\ColumnDoesNotExist;
use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException; use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Schema\Blueprint;
@@ -39,23 +40,20 @@ return new class() extends Migration {
*/ */
public function up(): void public function up(): void
{ {
try {
Schema::table( Schema::table(
'currency_exchange_rates', 'currency_exchange_rates',
function (Blueprint $table) { function (Blueprint $table) {
if (!Schema::hasColumn('currency_exchange_rates', 'user_group_id')) { if (!Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
try {
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id'); $table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
} catch (QueryException $e) {
Log::error(sprintf('Could not add column "user_group_id" to table "currency_exchange_rates": %s', $e->getMessage()));
}
try {
$table->foreign('user_group_id', 'cer_to_ugi')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade'); $table->foreign('user_group_id', 'cer_to_ugi')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');
} catch (QueryException $e) {
Log::error(sprintf('Could not add foreign key "cer_to_ugi" to table "currency_exchange_rates": %s', $e->getMessage()));
}
} }
} }
); );
} 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.');
}
} }
/** /**
@@ -65,22 +63,19 @@ return new class() extends Migration {
*/ */
public function down(): void public function down(): void
{ {
try {
Schema::table( Schema::table(
'currency_exchange_rates', 'currency_exchange_rates',
function (Blueprint $table) { function (Blueprint $table) {
try {
$table->dropForeign('cer_to_ugi'); $table->dropForeign('cer_to_ugi');
} catch (QueryException $e) {
Log::error(sprintf('Could not drop foreign key "cer_to_ugi" from table "currency_exchange_rates": %s', $e->getMessage()));
}
if (Schema::hasColumn('currency_exchange_rates', 'user_group_id')) { if (Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
try {
$table->dropColumn('user_group_id'); $table->dropColumn('user_group_id');
} catch (QueryException $e) {
Log::error(sprintf('Could not drop column "user_group_id" from table "currency_exchange_rates": %s', $e->getMessage()));
}
} }
} }
); );
} 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.');
}
} }
}; };

View File

@@ -34,7 +34,7 @@ return new class() extends Migration {
* *
* @return void * @return void
*/ */
public function up() public function up(): void
{ {
try { try {
Schema::create('notifications', function (Blueprint $table) { Schema::create('notifications', function (Blueprint $table) {
@@ -47,6 +47,7 @@ return new class() extends Migration {
}); });
} catch (QueryException $e) { } catch (QueryException $e) {
Log::error(sprintf('Could not create table "notifications": %s', $e->getMessage())); 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.');
} }
} }
@@ -55,7 +56,7 @@ return new class() extends Migration {
* *
* @return void * @return void
*/ */
public function down() public function down(): void
{ {
Schema::dropIfExists('notifications'); Schema::dropIfExists('notifications');
} }

View File

@@ -49,6 +49,7 @@ return new class() extends Migration {
}); });
} catch (QueryException $e) { } catch (QueryException $e) {
Log::error(sprintf('Could not create table "invited_users": %s', $e->getMessage())); 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.');
} }
} }

View File

@@ -34,7 +34,7 @@ return new class() extends Migration {
* *
* @return void * @return void
*/ */
public function up() public function up(): void
{ {
try { try {
Schema::create('audit_log_entries', function (Blueprint $table) { Schema::create('audit_log_entries', function (Blueprint $table) {
@@ -54,6 +54,7 @@ return new class() extends Migration {
}); });
} catch (QueryException $e) { } catch (QueryException $e) {
Log::error(sprintf('Could not create table "audit_log_entries": %s', $e->getMessage())); 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.');
} }
} }
@@ -62,7 +63,7 @@ return new class() extends Migration {
* *
* @return void * @return void
*/ */
public function down() public function down(): void
{ {
Schema::dropIfExists('audit_log_entries'); Schema::dropIfExists('audit_log_entries');
} }