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",
"version": "v3.15.1",
"version": "v3.16.0",
"source": {
"type": "git",
"url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git",
"reference": "d48755372a113bddb99f749e34805d83f3acfe04"
"reference": "d40f9436e1c448d309fa995ab9c14c5c7a96f2dc"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/d48755372a113bddb99f749e34805d83f3acfe04",
"reference": "d48755372a113bddb99f749e34805d83f3acfe04",
"url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/d40f9436e1c448d309fa995ab9c14c5c7a96f2dc",
"reference": "d40f9436e1c448d309fa995ab9c14c5c7a96f2dc",
"shasum": ""
},
"require": {
@ -463,7 +463,7 @@
],
"support": {
"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": [
{
@ -471,7 +471,7 @@
"type": "github"
}
],
"time": "2023-03-13T23:26:30+00:00"
"time": "2023-04-02T19:30:06+00:00"
},
{
"name": "psr/cache",

View File

@ -78,7 +78,7 @@ class NetWorth implements NetWorthInterface
$netWorth = [];
$result = [];
// Log::debug(sprintf('Now in getNetWorthByCurrency(%s)', $date->format('Y-m-d')));
// Log::debug(sprintf('Now in getNetWorthByCurrency(%s)', $date->format('Y-m-d')));
// get default currency
$default = app('amount')->getDefaultCurrencyByUser($this->user);
@ -89,11 +89,11 @@ class NetWorth implements NetWorthInterface
// get the preferred currency for this account
/** @var Account $account */
foreach ($accounts as $account) {
// Log::debug(sprintf('Now at account #%d: "%s"', $account->id, $account->name));
// Log::debug(sprintf('Now at account #%d: "%s"', $account->id, $account->name));
$currencyId = (int)$this->accountRepository->getMetaValue($account, 'currency_id');
$currencyId = 0 === $currencyId ? $default->id : $currencyId;
// Log::debug(sprintf('Currency ID is #%d', $currencyId));
// Log::debug(sprintf('Currency ID is #%d', $currencyId));
// balance in array:
$balance = $balances[$account->id] ?? '0';
@ -106,13 +106,13 @@ class NetWorth implements NetWorthInterface
$balance = bcsub($balance, $virtualBalance);
}
// Log::debug(sprintf('Balance corrected to %s because of virtual balance (%s)', $balance, $virtualBalance));
// Log::debug(sprintf('Balance corrected to %s because of virtual balance (%s)', $balance, $virtualBalance));
if (!array_key_exists($currencyId, $netWorth)) {
$netWorth[$currencyId] = '0';
}
$netWorth[$currencyId] = bcadd($balance, $netWorth[$currencyId]);
// Log::debug(sprintf('Total net worth for currency #%d is %s', $currencyId, $netWorth[$currencyId]));
// Log::debug(sprintf('Total net worth for currency #%d is %s', $currencyId, $netWorth[$currencyId]));
}
ksort($netWorth);

View File

@ -67,11 +67,11 @@ class BudgetLimitTransformer extends AbstractTransformer
*/
public function transform(BudgetLimit $budgetLimit): array
{
// $repository = app(OperationsRepository::class);
// $repository->setUser($budgetLimit->budget->user);
// $expenses = $repository->sumExpenses(
// $budgetLimit->start_date, $budgetLimit->end_date, null, new Collection([$budgetLimit->budget]), $budgetLimit->transactionCurrency
// );
// $repository = app(OperationsRepository::class);
// $repository->setUser($budgetLimit->budget->user);
// $expenses = $repository->sumExpenses(
// $budgetLimit->start_date, $budgetLimit->end_date, null, new Collection([$budgetLimit->budget]), $budgetLimit->transactionCurrency
// );
$currency = $budgetLimit->transactionCurrency;
$amount = $budgetLimit->amount;
$currencyDecimalPlaces = 2;

View File

@ -68,30 +68,30 @@ class BudgetTransformer extends AbstractTransformer
$start = $this->parameters->get('start');
$end = $this->parameters->get('end');
//$autoBudget = $this->repository->getAutoBudget($budget);
// $spent = [];
// if (null !== $start && null !== $end) {
// $spent = $this->beautify($this->opsRepository->sumExpenses($start, $end, null, new Collection([$budget])));
// }
// $spent = [];
// if (null !== $start && null !== $end) {
// $spent = $this->beautify($this->opsRepository->sumExpenses($start, $end, null, new Collection([$budget])));
// }
// $abCurrencyId = null;
// $abCurrencyCode = null;
// $abType = null;
// $abAmount = null;
// $abPeriod = null;
// $notes = $this->repository->getNoteText($budget);
//
// $types = [
// AutoBudget::AUTO_BUDGET_RESET => 'reset',
// AutoBudget::AUTO_BUDGET_ROLLOVER => 'rollover',
// ];
//
// if (null !== $autoBudget) {
// $abCurrencyId = (string) $autoBudget->transactionCurrency->id;
// $abCurrencyCode = $autoBudget->transactionCurrency->code;
// $abType = $types[$autoBudget->auto_budget_type];
// $abAmount = number_format((float) $autoBudget->amount, $autoBudget->transactionCurrency->decimal_places, '.', '');
// $abPeriod = $autoBudget->period;
// }
// $abCurrencyId = null;
// $abCurrencyCode = null;
// $abType = null;
// $abAmount = null;
// $abPeriod = null;
// $notes = $this->repository->getNoteText($budget);
//
// $types = [
// AutoBudget::AUTO_BUDGET_RESET => 'reset',
// AutoBudget::AUTO_BUDGET_ROLLOVER => 'rollover',
// ];
//
// if (null !== $autoBudget) {
// $abCurrencyId = (string) $autoBudget->transactionCurrency->id;
// $abCurrencyCode = $autoBudget->transactionCurrency->code;
// $abType = $types[$autoBudget->auto_budget_type];
// $abAmount = number_format((float) $autoBudget->amount, $autoBudget->transactionCurrency->decimal_places, '.', '');
// $abPeriod = $autoBudget->period;
// }
return [
'id' => (string)$budget->id,

View File

@ -41,8 +41,8 @@ return [
'host' => envNonEmpty('MAIL_HOST', 'smtp.mailtrap.io'),
'port' => (int)env('MAIL_PORT', 2525),
'encryption' => envNonEmpty('MAIL_ENCRYPTION', 'tls'),
'username' => envNonEmpty('MAIL_USERNAME','user@example.com'),
'password' => envNonEmpty('MAIL_PASSWORD','password'),
'username' => envNonEmpty('MAIL_USERNAME', 'user@example.com'),
'password' => envNonEmpty('MAIL_PASSWORD', 'password'),
'timeout' => null,
'verify_peer' => null !== env('MAIL_ENCRYPTION'),
],

View File

@ -22,6 +22,7 @@
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
/**
@ -67,9 +68,13 @@ class CreateSupportTables extends Migration
$this->createConfigurationTable();
}
/**
* @return void
*/
private function createAccountTypeTable(): void
{
if (!Schema::hasTable('account_types')) {
try {
Schema::create(
'account_types',
static function (Blueprint $table) {
@ -81,12 +86,20 @@ class CreateSupportTables extends Migration
$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
{
if (!Schema::hasTable('configuration')) {
try {
Schema::create(
'configuration',
static function (Blueprint $table) {
@ -97,12 +110,20 @@ class CreateSupportTables extends Migration
$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
{
if (!Schema::hasTable('transaction_currencies')) {
try {
Schema::create(
'transaction_currencies',
static function (Blueprint $table) {
@ -117,12 +138,20 @@ class CreateSupportTables extends Migration
$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
{
if (!Schema::hasTable('jobs')) {
try {
Schema::create(
'jobs',
static function (Blueprint $table) {
@ -138,12 +167,20 @@ class CreateSupportTables extends Migration
$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
{
if (!Schema::hasTable('password_resets')) {
try {
Schema::create(
'password_resets',
static function (Blueprint $table) {
@ -153,12 +190,20 @@ class CreateSupportTables extends Migration
$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
{
if (!Schema::hasTable('permission_role')) {
try {
Schema::create(
'permission_role',
static function (Blueprint $table) {
@ -171,12 +216,20 @@ class CreateSupportTables extends Migration
$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
{
if (!Schema::hasTable('permissions')) {
try {
Schema::create(
'permissions',
static function (Blueprint $table) {
@ -187,12 +240,20 @@ class CreateSupportTables extends Migration
$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
{
if (!Schema::hasTable('roles')) {
try {
Schema::create(
'roles',
static function (Blueprint $table) {
@ -203,12 +264,20 @@ class CreateSupportTables extends Migration
$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
{
if (!Schema::hasTable('sessions')) {
try {
Schema::create(
'sessions',
static function (Blueprint $table) {
@ -220,12 +289,20 @@ class CreateSupportTables extends Migration
$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
{
if (!Schema::hasTable('transaction_types')) {
try {
Schema::create(
'transaction_types',
static function (Blueprint $table) {
@ -238,6 +315,10 @@ class CreateSupportTables extends Migration
$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);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
/**
@ -47,6 +48,7 @@ class CreateUsersTable extends Migration
public function up(): void
{
if (!Schema::hasTable('users')) {
try {
Schema::create(
'users',
static function (Blueprint $table) {
@ -60,6 +62,10 @@ class CreateUsersTable extends Migration
$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);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
/**
@ -41,8 +42,8 @@ class CreateMainTables extends Migration
Schema::dropIfExists('attachments');
Schema::dropIfExists('limit_repetitions');
Schema::dropIfExists('budget_limits');
Schema::dropIfExists('export_jobs');
Schema::dropIfExists('import_jobs');
Schema::dropIfExists('export_jobs'); // table is no longer created
Schema::dropIfExists('import_jobs'); // table is no longer created
Schema::dropIfExists('preferences');
Schema::dropIfExists('role_user');
Schema::dropIfExists('rule_actions');
@ -79,7 +80,6 @@ class CreateMainTables extends Migration
$this->createBillsTable();
$this->createBudgetTables();
$this->createCategoriesTable();
$this->createExportJobsTable();
$this->createPreferencesTable();
$this->createRoleTable();
$this->createRuleTables();
@ -90,6 +90,7 @@ class CreateMainTables extends Migration
private function createAccountTables(): void
{
if (!Schema::hasTable('accounts')) {
try {
Schema::create(
'accounts',
static function (Blueprint $table) {
@ -107,9 +108,14 @@ class CreateMainTables extends Migration
$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')) {
try {
Schema::create(
'account_meta',
static function (Blueprint $table) {
@ -121,12 +127,17 @@ class CreateMainTables extends Migration
$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
{
if (!Schema::hasTable('attachments')) {
try {
Schema::create(
'attachments',
static function (Blueprint $table) {
@ -149,12 +160,17 @@ class CreateMainTables extends Migration
$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
{
if (!Schema::hasTable('bills')) {
try {
Schema::create(
'bills',
static function (Blueprint $table) {
@ -178,6 +194,10 @@ class CreateMainTables extends Migration
$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
{
if (!Schema::hasTable('budgets')) {
try {
Schema::create(
'budgets',
static function (Blueprint $table) {
@ -200,8 +221,13 @@ class CreateMainTables extends Migration
$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')) {
try {
Schema::create(
'budget_limits',
static function (Blueprint $table) {
@ -215,8 +241,13 @@ class CreateMainTables extends Migration
$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')) {
try {
Schema::create(
'limit_repetitions',
static function (Blueprint $table) {
@ -229,12 +260,20 @@ class CreateMainTables extends Migration
$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
{
if (!Schema::hasTable('categories')) {
try {
Schema::create(
'categories',
static function (Blueprint $table) {
@ -249,45 +288,18 @@ class CreateMainTables extends Migration
$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
{
if (!Schema::hasTable('piggy_banks')) {
try {
Schema::create(
'piggy_banks',
static function (Blueprint $table) {
@ -305,9 +317,14 @@ class CreateMainTables extends Migration
$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')) {
try {
Schema::create(
'piggy_bank_repetitions',
static function (Blueprint $table) {
@ -320,12 +337,17 @@ class CreateMainTables extends Migration
$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
{
if (!Schema::hasTable('preferences')) {
try {
Schema::create(
'preferences',
static function (Blueprint $table) {
@ -338,12 +360,20 @@ class CreateMainTables extends Migration
$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
{
if (!Schema::hasTable('role_user')) {
try {
Schema::create(
'role_user',
static function (Blueprint $table) {
@ -356,6 +386,10 @@ class CreateMainTables extends Migration
$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
{
if (!Schema::hasTable('rule_groups')) {
try {
Schema::create(
'rule_groups',
static function (Blueprint $table) {
@ -382,6 +417,10 @@ class CreateMainTables extends Migration
$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')) {
Schema::create(
@ -407,6 +446,7 @@ class CreateMainTables extends Migration
);
}
if (!Schema::hasTable('rule_actions')) {
try {
Schema::create(
'rule_actions',
static function (Blueprint $table) {
@ -425,8 +465,13 @@ class CreateMainTables extends Migration
$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')) {
try {
Schema::create(
'rule_triggers',
static function (Blueprint $table) {
@ -445,12 +490,20 @@ class CreateMainTables extends Migration
$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
{
if (!Schema::hasTable('tags')) {
try {
Schema::create(
'tags',
static function (Blueprint $table) {
@ -471,17 +524,20 @@ class CreateMainTables extends Migration
$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.
* @SuppressWarnings(PHPMD.NPathComplexity) // cannot be helped
* @SuppressWarnings(PHPMD.CyclomaticComplexity) // its exactly five
* @return void
*/
private function createTransactionTables(): void
{
if (!Schema::hasTable('transaction_journals')) {
try {
Schema::create(
'transaction_journals',
static function (Blueprint $table) {
@ -507,9 +563,14 @@ class CreateMainTables extends Migration
$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')) {
try {
Schema::create(
'journal_meta',
static function (Blueprint $table) {
@ -522,9 +583,14 @@ class CreateMainTables extends Migration
$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')) {
try {
Schema::create(
'tag_transaction_journal',
static function (Blueprint $table) {
@ -538,9 +604,14 @@ class CreateMainTables extends Migration
$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')) {
try {
Schema::create(
'budget_transaction_journal',
static function (Blueprint $table) {
@ -551,9 +622,14 @@ class CreateMainTables extends Migration
$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')) {
try {
Schema::create(
'category_transaction_journal',
static function (Blueprint $table) {
@ -564,9 +640,14 @@ class CreateMainTables extends Migration
$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')) {
try {
Schema::create(
'piggy_bank_events',
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');
}
);
} 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')) {
try {
Schema::create(
'transactions',
static function (Blueprint $table) {
@ -599,9 +685,14 @@ class CreateMainTables extends Migration
$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')) {
try {
Schema::create(
'budget_transaction',
static function (Blueprint $table) {
@ -613,9 +704,14 @@ class CreateMainTables extends Migration
$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')) {
try {
Schema::create(
'category_transaction',
static function (Blueprint $table) {
@ -627,6 +723,10 @@ class CreateMainTables extends Migration
$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);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
/**
@ -46,6 +47,7 @@ class ChangesForV410 extends Migration
*/
public function up(): void
{
try {
Schema::create(
'notes',
static function (Blueprint $table) {
@ -58,5 +60,9 @@ class ChangesForV410 extends Migration
$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);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
/**
@ -46,6 +47,7 @@ class ChangesForV430 extends Migration
*/
public function up(): void
{
try {
Schema::create(
'available_budgets',
static function (Blueprint $table) {
@ -62,5 +64,9 @@ class ChangesForV430 extends Migration
$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);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
/**
@ -62,6 +63,7 @@ class ChangesForV440 extends Migration
public function up(): void
{
if (!Schema::hasTable('currency_exchange_rates')) {
try {
Schema::create(
'currency_exchange_rates',
static function (Blueprint $table) {
@ -80,6 +82,10 @@ class ChangesForV440 extends Migration
$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(

View File

@ -22,6 +22,7 @@
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -49,6 +50,7 @@ class ChangesForV470 extends Migration
public function up(): void
{
if (!Schema::hasTable('link_types')) {
try {
Schema::create(
'link_types',
static function (Blueprint $table) {
@ -63,9 +65,14 @@ class ChangesForV470 extends Migration
$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')) {
try {
Schema::create(
'journal_links',
static function (Blueprint $table) {
@ -83,6 +90,10 @@ class ChangesForV470 extends Migration
$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);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -47,6 +48,7 @@ class CreateOauthAuthCodesTable extends Migration
*/
public function up(): void
{
try {
Schema::create(
'oauth_auth_codes',
static function (Blueprint $table) {
@ -58,5 +60,9 @@ class CreateOauthAuthCodesTable extends Migration
$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);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -47,6 +48,7 @@ class CreateOauthAccessTokensTable extends Migration
*/
public function up(): void
{
try {
Schema::create(
'oauth_access_tokens',
static function (Blueprint $table) {
@ -60,5 +62,9 @@ class CreateOauthAccessTokensTable extends Migration
$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);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -47,6 +48,7 @@ class CreateOauthRefreshTokensTable extends Migration
*/
public function up(): void
{
try {
Schema::create(
'oauth_refresh_tokens',
static function (Blueprint $table) {
@ -56,5 +58,9 @@ class CreateOauthRefreshTokensTable extends Migration
$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);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -47,6 +48,7 @@ class CreateOauthClientsTable extends Migration
*/
public function up(): void
{
try {
Schema::create(
'oauth_clients',
static function (Blueprint $table) {
@ -61,5 +63,9 @@ class CreateOauthClientsTable extends Migration
$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);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -47,6 +48,7 @@ class CreateOauthPersonalAccessClientsTable extends Migration
*/
public function up(): void
{
try {
Schema::create(
'oauth_personal_access_clients',
static function (Blueprint $table) {
@ -55,5 +57,9 @@ class CreateOauthPersonalAccessClientsTable extends Migration
$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);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
/**
@ -55,6 +56,7 @@ class ChangesForV475 extends Migration
*/
public function up(): void
{
try {
Schema::create(
'recurrences',
static function (Blueprint $table) {
@ -79,7 +81,11 @@ class ChangesForV475 extends Migration
$table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');
}
);
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "recurrences": %s', $e->getMessage()));
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
}
try {
Schema::create(
'recurrences_transactions',
static function (Blueprint $table) {
@ -103,7 +109,12 @@ class ChangesForV475 extends Migration
$table->foreign('destination_id')->references('id')->on('accounts')->onDelete('cascade');
}
);
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "recurrences_transactions": %s', $e->getMessage()));
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
}
try {
Schema::create(
'recurrences_repetitions',
static function (Blueprint $table) {
@ -119,7 +130,12 @@ class ChangesForV475 extends Migration
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
}
);
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "recurrences_repetitions": %s', $e->getMessage()));
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
}
try {
Schema::create(
'recurrences_meta',
static function (Blueprint $table) {
@ -134,7 +150,11 @@ class ChangesForV475 extends Migration
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
}
);
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "recurrences_meta": %s', $e->getMessage()));
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
}
try {
Schema::create(
'rt_meta',
static function (Blueprint $table) {
@ -149,5 +169,9 @@ class ChangesForV475 extends Migration
$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
*/
public function down()
public function down(): void
{
Schema::table(
'transaction_currencies',
@ -53,7 +53,7 @@ class ChangesForV479 extends Migration
*
* @return void
*/
public function up()
public function up(): void
{
Schema::table(
'transaction_currencies',

View File

@ -23,6 +23,7 @@
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -53,6 +54,7 @@ class ChangesForV4710 extends Migration
public function up(): void
{
if (!Schema::hasTable('transaction_groups')) {
try {
Schema::create(
'transaction_groups',
static function (Blueprint $table) {
@ -65,9 +67,14 @@ class ChangesForV4710 extends Migration
$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')) {
try {
Schema::create(
'group_journals',
static function (Blueprint $table) {
@ -82,6 +89,10 @@ class ChangesForV4710 extends Migration
$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);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -38,7 +39,7 @@ class MakeLocationsTable extends Migration
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('locations');
}
@ -48,8 +49,9 @@ class MakeLocationsTable extends Migration
*
* @return void
*/
public function up()
public function up(): void
{
try {
Schema::create(
'locations',
static function (Blueprint $table) {
@ -65,5 +67,9 @@ class MakeLocationsTable extends Migration
$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);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
/**
@ -50,6 +51,7 @@ class ChangesForV520 extends Migration
public function up(): void
{
if (!Schema::hasTable('auto_budgets')) {
try {
Schema::create(
'auto_budgets',
static function (Blueprint $table) {
@ -66,24 +68,10 @@ class ChangesForV520 extends Migration
$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()));
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('telemetry')) {
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);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
/**
@ -51,6 +52,7 @@ class ChangesForV530 extends Migration
public function up(): void
{
if (!Schema::hasTable('object_groups')) {
try {
Schema::create(
'object_groups',
static function (Blueprint $table) {
@ -63,8 +65,14 @@ class ChangesForV530 extends Migration
$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')) {
try {
Schema::create(
'object_groupables',
static function (Blueprint $table) {
@ -73,6 +81,10 @@ class ChangesForV530 extends Migration
$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);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -36,10 +37,12 @@ class ChangesForV550 extends Migration
*
* @return void
*/
public function down()
public function down(): void
{
// recreate jobs table.
Schema::dropIfExists('jobs');
try {
Schema::create(
'jobs',
static function (Blueprint $table) {
@ -55,6 +58,10 @@ class ChangesForV550 extends Migration
$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.
Schema::table(
@ -86,11 +93,12 @@ class ChangesForV550 extends Migration
*
* @return void
*/
public function up()
public function up(): void
{
// drop and recreate jobs table.
Schema::dropIfExists('jobs');
// this is the NEW table
try {
Schema::create(
'jobs',
function (Blueprint $table) {
@ -103,10 +111,15 @@ class ChangesForV550 extends Migration
$table->unsignedInteger('created_at');
}
);
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "jobs": %s', $e->getMessage()));
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
}
// drop failed jobs table.
Schema::dropIfExists('failed_jobs');
// create new failed_jobs table.
try {
Schema::create(
'failed_jobs',
function (Blueprint $table) {
@ -119,6 +132,10 @@ class ChangesForV550 extends Migration
$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.
Schema::table(
@ -147,6 +164,7 @@ class ChangesForV550 extends Migration
// new webhooks table
if (!Schema::hasTable('webhooks')) {
try {
Schema::create(
'webhooks',
static function (Blueprint $table) {
@ -165,10 +183,15 @@ class ChangesForV550 extends Migration
$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
if (!Schema::hasTable('webhook_messages')) {
try {
Schema::create(
'webhook_messages',
static function (Blueprint $table) {
@ -185,9 +208,14 @@ class ChangesForV550 extends Migration
$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')) {
try {
Schema::create(
'webhook_attempts',
static function (Blueprint $table) {
@ -203,6 +231,10 @@ class ChangesForV550 extends Migration
$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.
*/
public function down()
public function down(): void
{
Schema::table(
'users',
@ -44,7 +44,7 @@ class AddLdapColumnsToUsersTable extends Migration
/**
* Run the migrations.
*/
public function up()
public function up(): void
{
Schema::table(
'users',

View File

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

View File

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

View File

@ -23,6 +23,7 @@
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
@ -53,7 +54,7 @@ class UserGroups extends Migration
*
* @return void
*/
public function down()
public function down(): void
{
// remove columns from tables
/** @var string $tableName */
@ -89,12 +90,13 @@ class UserGroups extends Migration
*
* @return void
*/
public function up()
public function up(): void
{
/*
* user is a member of a user_group through a user_group_role
* may have multiple roles in a group
*/
try {
Schema::create(
'user_groups',
static function (Blueprint $table) {
@ -106,7 +108,11 @@ class UserGroups extends Migration
$table->unique('title');
}
);
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "user_groups": %s', $e->getMessage()));
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
}
try {
Schema::create(
'user_roles',
static function (Blueprint $table) {
@ -118,7 +124,12 @@ class UserGroups extends Migration
$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(
'group_memberships',
static function (Blueprint $table) {
@ -135,6 +146,10 @@ class UserGroups extends Migration
$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(
'users',
function (Blueprint $table) {

View File

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

@ -31,7 +31,7 @@ use Illuminate\Support\Facades\Schema;
/**
*
*/
return new class() extends Migration {
return new class () extends Migration {
/**
* Run the migrations.
*
@ -47,11 +47,13 @@ return new class() extends Migration {
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
} catch (QueryException $e) {
Log::error(sprintf('Could not add column "user_group_id" to table "currency_exchange_rates": %s', $e->getMessage()));
Log::error('If the column exists already (see error), this is not a problem. Otherwise, please create a GitHub discussion.');
}
try {
$table->foreign('user_group_id', 'cer_to_ugi')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');
} catch (QueryException $e) {
Log::error(sprintf('Could not add foreign key "cer_to_ugi" to table "currency_exchange_rates": %s', $e->getMessage()));
Log::error('If the foreign key exists already (see error), this is not a problem. Otherwise, please create a GitHub discussion.');
}
}
}
@ -72,12 +74,14 @@ return new class() extends Migration {
$table->dropForeign('cer_to_ugi');
} catch (QueryException $e) {
Log::error(sprintf('Could not drop foreign key "cer_to_ugi" from table "currency_exchange_rates": %s', $e->getMessage()));
Log::error('If the foreign key does not exist (see error message), this is not a problem. Otherwise, please create a GitHub discussion.');
}
if (Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
try {
$table->dropColumn('user_group_id');
} catch (QueryException $e) {
Log::error(sprintf('Could not drop column "user_group_id" from table "currency_exchange_rates": %s', $e->getMessage()));
Log::error('If the column does not exist (see error message), this is not a problem. Otherwise, please create a GitHub discussion.');
}
}
}

View File

@ -28,13 +28,13 @@ use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
try {
Schema::create('notifications', function (Blueprint $table) {
@ -47,6 +47,7 @@ return new class() extends Migration {
});
} 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.');
}
}
@ -55,7 +56,7 @@ return new class() extends Migration {
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('notifications');
}

View File

@ -28,7 +28,7 @@ use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
return new class () extends Migration {
/**
* Run the migrations.
*
@ -49,6 +49,7 @@ return new class() extends Migration {
});
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "invited_users": %s', $e->getMessage()));
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
}
}

View File

@ -28,13 +28,13 @@ use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Schema;
return new class() extends Migration {
return new class () extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
public function up(): void
{
try {
Schema::create('audit_log_entries', function (Blueprint $table) {
@ -54,6 +54,7 @@ return new class() extends Migration {
});
} catch (QueryException $e) {
Log::error(sprintf('Could not create table "audit_log_entries": %s', $e->getMessage()));
Log::error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
}
}
@ -62,7 +63,7 @@ return new class() extends Migration {
*
* @return void
*/
public function down()
public function down(): void
{
Schema::dropIfExists('audit_log_entries');
}