Catch errors in database table create statements.

This commit is contained in:
James Cole 2023-04-07 18:21:12 +02:00
parent 40e2bf7cac
commit dd11f98be7
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
34 changed files with 1386 additions and 1039 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

@ -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,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;
/** /**
@ -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

@ -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;
/** /**
@ -62,6 +63,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,6 +82,10 @@ 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.');
}
} }
Schema::table( Schema::table(

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

@ -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

@ -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

@ -37,7 +37,7 @@ class ChangesForV479 extends Migration
* *
* @return void * @return void
*/ */
public function down() public function down(): void
{ {
Schema::table( Schema::table(
'transaction_currencies', 'transaction_currencies',
@ -53,7 +53,7 @@ class ChangesForV479 extends Migration
* *
* @return void * @return void
*/ */
public function up() public function up(): void
{ {
Schema::table( Schema::table(
'transaction_currencies', 'transaction_currencies',

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;
@ -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

@ -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,10 +37,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,6 +58,10 @@ 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.
Schema::table( Schema::table(
@ -86,11 +93,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 +111,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,6 +132,10 @@ 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.
Schema::table( Schema::table(
@ -147,6 +164,7 @@ class ChangesForV550 extends Migration
// 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 +183,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 +208,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 +231,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

@ -31,7 +31,7 @@ class AddLdapColumnsToUsersTable extends Migration
/** /**
* Reverse the migrations. * Reverse the migrations.
*/ */
public function down() public function down(): void
{ {
Schema::table( Schema::table(
'users', 'users',
@ -44,7 +44,7 @@ class AddLdapColumnsToUsersTable extends Migration
/** /**
* Run the migrations. * Run the migrations.
*/ */
public function up() public function up(): void
{ {
Schema::table( Schema::table(
'users', 'users',

View File

@ -36,7 +36,7 @@ class ExtendCurrencyInfo extends Migration
* *
* @return void * @return void
*/ */
public function down() public function down(): void
{ {
// //
} }
@ -46,7 +46,7 @@ class ExtendCurrencyInfo extends Migration
* *
* @return void * @return void
*/ */
public function up() public function up(): void
{ {
Schema::table( Schema::table(
'transaction_currencies', 'transaction_currencies',

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

@ -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,7 +54,7 @@ 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 */
@ -89,12 +90,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 +108,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 +124,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 +146,10 @@ 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.');
}
Schema::table( Schema::table(
'users', 'users',
function (Blueprint $table) { function (Blueprint $table) {

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

@ -47,11 +47,13 @@ return new class() extends Migration {
$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) { } catch (QueryException $e) {
Log::error(sprintf('Could not add column "user_group_id" to table "currency_exchange_rates": %s', $e->getMessage())); Log::error(sprintf('Could not add column "user_group_id" to table "currency_exchange_rates": %s', $e->getMessage()));
Log::error('If the column exists already (see error), this is not a problem. Otherwise, please create a GitHub discussion.');
} }
try { 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) { } catch (QueryException $e) {
Log::error(sprintf('Could not add foreign key "cer_to_ugi" to table "currency_exchange_rates": %s', $e->getMessage())); Log::error(sprintf('Could not add foreign key "cer_to_ugi" to table "currency_exchange_rates": %s', $e->getMessage()));
Log::error('If the foreign key exists already (see error), this is not a problem. Otherwise, please create a GitHub discussion.');
} }
} }
} }
@ -72,12 +74,14 @@ return new class() extends Migration {
$table->dropForeign('cer_to_ugi'); $table->dropForeign('cer_to_ugi');
} catch (QueryException $e) { } catch (QueryException $e) {
Log::error(sprintf('Could not drop foreign key "cer_to_ugi" from table "currency_exchange_rates": %s', $e->getMessage())); Log::error(sprintf('Could not drop foreign key "cer_to_ugi" from table "currency_exchange_rates": %s', $e->getMessage()));
Log::error('If the foreign key does not exist (see error message), this is not a problem. Otherwise, please create a GitHub discussion.');
} }
if (Schema::hasColumn('currency_exchange_rates', 'user_group_id')) { if (Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
try { try {
$table->dropColumn('user_group_id'); $table->dropColumn('user_group_id');
} catch (QueryException $e) { } catch (QueryException $e) {
Log::error(sprintf('Could not drop column "user_group_id" from table "currency_exchange_rates": %s', $e->getMessage())); Log::error(sprintf('Could not drop column "user_group_id" from table "currency_exchange_rates": %s', $e->getMessage()));
Log::error('If the column does not exist (see error message), this is not a problem. Otherwise, please create a GitHub discussion.');
} }
} }
} }

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