Compare commits

...

3 Commits

Author SHA1 Message Date
github-actions[bot]
5f8d7049b5 Merge pull request #11622 from firefly-iii/release-1769628396
🤖 Automatically merge the PR into the develop branch.
2026-01-28 20:26:45 +01:00
JC5
7e80f78f2e 🤖 Auto commit for release 'develop' on 2026-01-28 2026-01-28 20:26:36 +01:00
James Cole
ad922745c4 Fix #11620 2026-01-28 20:22:11 +01:00
60 changed files with 1309 additions and 1648 deletions

View File

@@ -79,7 +79,7 @@ return [
// see cer.php for exchange rates feature flag.
],
'version' => 'develop/2026-01-28',
'build_time' => 1769627488,
'build_time' => 1769628267,
'api_version' => '2.1.0', // field is no longer used.
'db_version' => 28, // field is no longer used.

View File

@@ -76,17 +76,14 @@ class CreateSupportTables extends Migration
{
if (!Schema::hasTable('account_types')) {
try {
Schema::create(
'account_types',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->string('type', 50);
Schema::create('account_types', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->string('type', 50);
// type must be unique.
$table->unique(['type']);
}
);
// type must be unique.
$table->unique(['type']);
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'account_types', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -98,20 +95,17 @@ class CreateSupportTables extends Migration
{
if (!Schema::hasTable('transaction_currencies')) {
try {
Schema::create(
'transaction_currencies',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->string('code', 3);
$table->string('name', 255);
$table->string('symbol', 12);
Schema::create('transaction_currencies', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->string('code', 3);
$table->string('name', 255);
$table->string('symbol', 12);
// code must be unique.
$table->unique(['code']);
}
);
// code must be unique.
$table->unique(['code']);
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'transaction_currencies', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -123,18 +117,15 @@ class CreateSupportTables extends Migration
{
if (!Schema::hasTable('transaction_types')) {
try {
Schema::create(
'transaction_types',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->string('type', 50);
Schema::create('transaction_types', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->string('type', 50);
// type must be unique.
$table->unique(['type']);
}
);
// type must be unique.
$table->unique(['type']);
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'transaction_types', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -146,21 +137,18 @@ class CreateSupportTables extends Migration
{
if (!Schema::hasTable('jobs')) {
try {
Schema::create(
'jobs',
static function (Blueprint $table): void {
// straight from Laravel
$table->bigIncrements('id');
$table->string('queue');
$table->longText('payload');
$table->tinyInteger('attempts')->unsigned();
$table->tinyInteger('reserved')->unsigned();
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
$table->index(['queue', 'reserved', 'reserved_at']);
}
);
Schema::create('jobs', static function (Blueprint $table): void {
// straight from Laravel
$table->bigIncrements('id');
$table->string('queue');
$table->longText('payload');
$table->tinyInteger('attempts')->unsigned();
$table->tinyInteger('reserved')->unsigned();
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
$table->index(['queue', 'reserved', 'reserved_at']);
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'jobs', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -172,15 +160,12 @@ class CreateSupportTables extends Migration
{
if (!Schema::hasTable('password_resets')) {
try {
Schema::create(
'password_resets',
static function (Blueprint $table): void {
// straight from laravel
$table->string('email')->index();
$table->string('token')->index();
$table->timestamp('created_at')->nullable();
}
);
Schema::create('password_resets', static function (Blueprint $table): void {
// straight from laravel
$table->string('email')->index();
$table->string('token')->index();
$table->timestamp('created_at')->nullable();
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'password_resets', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -192,16 +177,13 @@ class CreateSupportTables extends Migration
{
if (!Schema::hasTable('permissions')) {
try {
Schema::create(
'permissions',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->string('name')->unique();
$table->string('display_name')->nullable();
$table->string('description')->nullable();
}
);
Schema::create('permissions', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->string('name')->unique();
$table->string('display_name')->nullable();
$table->string('description')->nullable();
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'permissions', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -213,16 +195,13 @@ class CreateSupportTables extends Migration
{
if (!Schema::hasTable('roles')) {
try {
Schema::create(
'roles',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->string('name')->unique();
$table->string('display_name')->nullable();
$table->string('description')->nullable();
}
);
Schema::create('roles', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->string('name')->unique();
$table->string('display_name')->nullable();
$table->string('description')->nullable();
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'roles', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -234,18 +213,15 @@ class CreateSupportTables extends Migration
{
if (!Schema::hasTable('permission_role')) {
try {
Schema::create(
'permission_role',
static function (Blueprint $table): void {
$table->integer('permission_id')->unsigned();
$table->integer('role_id')->unsigned();
Schema::create('permission_role', static function (Blueprint $table): void {
$table->integer('permission_id')->unsigned();
$table->integer('role_id')->unsigned();
$table->foreign('permission_id')->references('id')->on('permissions')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('permission_id')->references('id')->on('permissions')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')->onUpdate('cascade')->onDelete('cascade');
$table->primary(['permission_id', 'role_id']);
}
);
$table->primary(['permission_id', 'role_id']);
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'permission_role', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -257,17 +233,14 @@ class CreateSupportTables extends Migration
{
if (!Schema::hasTable('sessions')) {
try {
Schema::create(
'sessions',
static function (Blueprint $table): void {
$table->string('id')->unique();
$table->integer('user_id')->nullable();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->text('payload');
$table->integer('last_activity');
}
);
Schema::create('sessions', static function (Blueprint $table): void {
$table->string('id')->unique();
$table->integer('user_id')->nullable();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->text('payload');
$table->integer('last_activity');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'sessions', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -279,16 +252,13 @@ class CreateSupportTables extends Migration
{
if (!Schema::hasTable('configuration')) {
try {
Schema::create(
'configuration',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->string('name', 50);
$table->text('data');
}
);
Schema::create('configuration', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->string('name', 50);
$table->text('data');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'configuration', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);

View File

@@ -53,19 +53,16 @@ class CreateUsersTable extends Migration
{
if (!Schema::hasTable('users')) {
try {
Schema::create(
'users',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->string('email', 255);
$table->string('password', 60);
$table->string('remember_token', 100)->nullable();
$table->string('reset', 32)->nullable();
$table->tinyInteger('blocked', false, true)->default('0');
$table->string('blocked_code', 25)->nullable();
}
);
Schema::create('users', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->string('email', 255);
$table->string('password', 60);
$table->string('remember_token', 100)->nullable();
$table->string('reset', 32)->nullable();
$table->tinyInteger('blocked', false, true)->default('0');
$table->string('blocked_code', 25)->nullable();
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'users', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);

View File

@@ -95,23 +95,20 @@ class CreateMainTables extends Migration
{
if (!Schema::hasTable('accounts')) {
try {
Schema::create(
'accounts',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('account_type_id', false, true);
$table->string('name', 1024);
$table->decimal('virtual_balance', 32, 12)->nullable();
$table->string('iban', 255)->nullable();
$table->boolean('active')->default(1);
$table->boolean('encrypted')->default(0);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('account_type_id')->references('id')->on('account_types')->onDelete('cascade');
}
);
Schema::create('accounts', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('account_type_id', false, true);
$table->string('name', 1024);
$table->decimal('virtual_balance', 32, 12)->nullable();
$table->string('iban', 255)->nullable();
$table->boolean('active')->default(1);
$table->boolean('encrypted')->default(0);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('account_type_id')->references('id')->on('account_types')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'accounts', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -120,17 +117,14 @@ class CreateMainTables extends Migration
if (!Schema::hasTable('account_meta')) {
try {
Schema::create(
'account_meta',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('account_id', false, true);
$table->string('name');
$table->text('data');
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
}
);
Schema::create('account_meta', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('account_id', false, true);
$table->string('name');
$table->text('data');
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'account_meta', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -142,23 +136,20 @@ class CreateMainTables extends Migration
{
if (!Schema::hasTable('piggy_banks')) {
try {
Schema::create(
'piggy_banks',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('account_id', false, true);
$table->string('name', 1024);
$table->decimal('targetamount', 32, 12);
$table->date('startdate')->nullable();
$table->date('targetdate')->nullable();
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(0);
$table->boolean('encrypted')->default(1);
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
}
);
Schema::create('piggy_banks', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('account_id', false, true);
$table->string('name', 1024);
$table->decimal('targetamount', 32, 12);
$table->date('startdate')->nullable();
$table->date('targetdate')->nullable();
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(0);
$table->boolean('encrypted')->default(1);
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'piggy_banks', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -167,18 +158,15 @@ class CreateMainTables extends Migration
if (!Schema::hasTable('piggy_bank_repetitions')) {
try {
Schema::create(
'piggy_bank_repetitions',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('piggy_bank_id', false, true);
$table->date('startdate')->nullable();
$table->date('targetdate')->nullable();
$table->decimal('currentamount', 32, 12);
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
}
);
Schema::create('piggy_bank_repetitions', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('piggy_bank_id', false, true);
$table->date('startdate')->nullable();
$table->date('targetdate')->nullable();
$table->decimal('currentamount', 32, 12);
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'piggy_bank_repetitions', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -190,28 +178,25 @@ class CreateMainTables extends Migration
{
if (!Schema::hasTable('attachments')) {
try {
Schema::create(
'attachments',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('attachable_id', false, true);
$table->string('attachable_type', 255);
$table->string('md5', 128);
$table->string('filename', 1024);
$table->string('title', 1024)->nullable();
$table->text('description')->nullable();
$table->text('notes')->nullable();
$table->string('mime', 1024);
$table->integer('size', false, true);
$table->boolean('uploaded')->default(1);
Schema::create('attachments', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('attachable_id', false, true);
$table->string('attachable_type', 255);
$table->string('md5', 128);
$table->string('filename', 1024);
$table->string('title', 1024)->nullable();
$table->text('description')->nullable();
$table->text('notes')->nullable();
$table->string('mime', 1024);
$table->integer('size', false, true);
$table->boolean('uploaded')->default(1);
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'attachments', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -223,29 +208,26 @@ class CreateMainTables extends Migration
{
if (!Schema::hasTable('bills')) {
try {
Schema::create(
'bills',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('name', 1024);
$table->string('match', 1024);
$table->decimal('amount_min', 32, 12);
$table->decimal('amount_max', 32, 12);
$table->date('date');
$table->string('repeat_freq', 30);
$table->smallInteger('skip', false, true)->default(0);
$table->boolean('automatch')->default(1);
$table->boolean('active')->default(1);
$table->boolean('name_encrypted')->default(0);
$table->boolean('match_encrypted')->default(0);
Schema::create('bills', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('name', 1024);
$table->string('match', 1024);
$table->decimal('amount_min', 32, 12);
$table->decimal('amount_max', 32, 12);
$table->date('date');
$table->string('repeat_freq', 30);
$table->smallInteger('skip', false, true)->default(0);
$table->boolean('automatch')->default(1);
$table->boolean('active')->default(1);
$table->boolean('name_encrypted')->default(0);
$table->boolean('match_encrypted')->default(0);
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'bills', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -257,19 +239,16 @@ class CreateMainTables extends Migration
{
if (!Schema::hasTable('budgets')) {
try {
Schema::create(
'budgets',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('name', 1024);
$table->boolean('active')->default(1);
$table->boolean('encrypted')->default(0);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
Schema::create('budgets', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('name', 1024);
$table->boolean('active')->default(1);
$table->boolean('encrypted')->default(0);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'budgets', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -277,19 +256,16 @@ class CreateMainTables extends Migration
}
if (!Schema::hasTable('budget_limits')) {
try {
Schema::create(
'budget_limits',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('budget_id', false, true);
$table->date('startdate');
$table->decimal('amount', 32, 12);
$table->string('repeat_freq', 30)->nullable();
$table->boolean('repeats')->default(0);
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
}
);
Schema::create('budget_limits', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('budget_id', false, true);
$table->date('startdate');
$table->decimal('amount', 32, 12);
$table->string('repeat_freq', 30)->nullable();
$table->boolean('repeats')->default(0);
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'budget_limits', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -301,20 +277,17 @@ class CreateMainTables extends Migration
{
if (!Schema::hasTable('categories')) {
try {
Schema::create(
'categories',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('name', 1024);
$table->boolean('encrypted')->default(0);
Schema::create('categories', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('name', 1024);
$table->boolean('encrypted')->default(0);
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'categories', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -326,18 +299,15 @@ class CreateMainTables extends Migration
{
if (!Schema::hasTable('preferences')) {
try {
Schema::create(
'preferences',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('user_id', false, true);
$table->string('name', 1024);
$table->text('data');
Schema::create('preferences', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('user_id', false, true);
$table->string('name', 1024);
$table->text('data');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'preferences', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -349,18 +319,15 @@ class CreateMainTables extends Migration
{
if (!Schema::hasTable('role_user')) {
try {
Schema::create(
'role_user',
static function (Blueprint $table): void {
$table->integer('user_id', false, true);
$table->integer('role_id', false, true);
Schema::create('role_user', static function (Blueprint $table): void {
$table->integer('user_id', false, true);
$table->integer('role_id', false, true);
$table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('role_id')->references('id')->on('roles')->onUpdate('cascade')->onDelete('cascade');
$table->primary(['user_id', 'role_id']);
}
);
$table->primary(['user_id', 'role_id']);
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'role_user', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -375,22 +342,19 @@ class CreateMainTables extends Migration
{
if (!Schema::hasTable('rule_groups')) {
try {
Schema::create(
'rule_groups',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('title', 255);
$table->text('description')->nullable();
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(1);
Schema::create('rule_groups', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('title', 255);
$table->text('description')->nullable();
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(1);
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'rule_groups', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -398,27 +362,24 @@ class CreateMainTables extends Migration
}
if (!Schema::hasTable('rules')) {
try {
Schema::create(
'rules',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('rule_group_id', false, true);
$table->string('title', 255);
$table->text('description')->nullable();
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(1);
$table->boolean('stop_processing')->default(0);
Schema::create('rules', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('rule_group_id', false, true);
$table->string('title', 255);
$table->text('description')->nullable();
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(1);
$table->boolean('stop_processing')->default(0);
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
// link rule group id to rule group table
$table->foreign('rule_group_id')->references('id')->on('rule_groups')->onDelete('cascade');
}
);
// link rule group id to rule group table
$table->foreign('rule_group_id')->references('id')->on('rule_groups')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'rules', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -426,24 +387,21 @@ class CreateMainTables extends Migration
}
if (!Schema::hasTable('rule_actions')) {
try {
Schema::create(
'rule_actions',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('rule_id', false, true);
Schema::create('rule_actions', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('rule_id', false, true);
$table->string('action_type', 50);
$table->string('action_value', 255);
$table->string('action_type', 50);
$table->string('action_value', 255);
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(1);
$table->boolean('stop_processing')->default(0);
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(1);
$table->boolean('stop_processing')->default(0);
// link rule id to rules table
$table->foreign('rule_id')->references('id')->on('rules')->onDelete('cascade');
}
);
// link rule id to rules table
$table->foreign('rule_id')->references('id')->on('rules')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'rule_actions', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -451,24 +409,21 @@ class CreateMainTables extends Migration
}
if (!Schema::hasTable('rule_triggers')) {
try {
Schema::create(
'rule_triggers',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('rule_id', false, true);
Schema::create('rule_triggers', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('rule_id', false, true);
$table->string('trigger_type', 50);
$table->string('trigger_value', 255);
$table->string('trigger_type', 50);
$table->string('trigger_value', 255);
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(1);
$table->boolean('stop_processing')->default(0);
$table->integer('order', false, true)->default(0);
$table->boolean('active')->default(1);
$table->boolean('stop_processing')->default(0);
// link rule id to rules table
$table->foreign('rule_id')->references('id')->on('rules')->onDelete('cascade');
}
);
// link rule id to rules table
$table->foreign('rule_id')->references('id')->on('rules')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'rule_triggers', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -480,26 +435,23 @@ class CreateMainTables extends Migration
{
if (!Schema::hasTable('tags')) {
try {
Schema::create(
'tags',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
Schema::create('tags', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('tag', 1024);
$table->string('tagMode', 1024);
$table->date('date')->nullable();
$table->text('description')->nullable();
$table->decimal('latitude', 12, 8)->nullable();
$table->decimal('longitude', 12, 8)->nullable();
$table->smallInteger('zoomLevel', false, true)->nullable();
$table->string('tag', 1024);
$table->string('tagMode', 1024);
$table->date('date')->nullable();
$table->text('description')->nullable();
$table->decimal('latitude', 12, 8)->nullable();
$table->decimal('longitude', 12, 8)->nullable();
$table->smallInteger('zoomLevel', false, true)->nullable();
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
// link user id to users table
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'tags', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -515,31 +467,28 @@ class CreateMainTables extends Migration
{
if (!Schema::hasTable('transaction_journals')) {
try {
Schema::create(
'transaction_journals',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('transaction_type_id', false, true);
$table->integer('bill_id', false, true)->nullable();
$table->integer('transaction_currency_id', false, true);
$table->string('description', 1024);
$table->date('date');
$table->date('interest_date')->nullable();
$table->date('book_date')->nullable();
$table->date('process_date')->nullable();
$table->integer('order', false, true)->default(0);
$table->integer('tag_count', false, true);
$table->boolean('encrypted')->default(1);
$table->boolean('completed')->default(1);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');
$table->foreign('bill_id')->references('id')->on('bills')->onDelete('set null');
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
}
);
Schema::create('transaction_journals', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('transaction_type_id', false, true);
$table->integer('bill_id', false, true)->nullable();
$table->integer('transaction_currency_id', false, true);
$table->string('description', 1024);
$table->date('date');
$table->date('interest_date')->nullable();
$table->date('book_date')->nullable();
$table->date('process_date')->nullable();
$table->integer('order', false, true)->default(0);
$table->integer('tag_count', false, true);
$table->boolean('encrypted')->default(1);
$table->boolean('completed')->default(1);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');
$table->foreign('bill_id')->references('id')->on('bills')->onDelete('set null');
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'transaction_journals', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -548,18 +497,15 @@ class CreateMainTables extends Migration
if (!Schema::hasTable('journal_meta')) {
try {
Schema::create(
'journal_meta',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('transaction_journal_id', false, true);
$table->string('name', 255);
$table->text('data');
$table->string('hash', 64);
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
}
);
Schema::create('journal_meta', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('transaction_journal_id', false, true);
$table->string('name', 255);
$table->text('data');
$table->string('hash', 64);
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'journal_meta', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -568,19 +514,16 @@ class CreateMainTables extends Migration
if (!Schema::hasTable('tag_transaction_journal')) {
try {
Schema::create(
'tag_transaction_journal',
static function (Blueprint $table): void {
$table->increments('id');
$table->integer('tag_id', false, true);
$table->integer('transaction_journal_id', false, true);
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade');
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
Schema::create('tag_transaction_journal', static function (Blueprint $table): void {
$table->increments('id');
$table->integer('tag_id', false, true);
$table->integer('transaction_journal_id', false, true);
$table->foreign('tag_id')->references('id')->on('tags')->onDelete('cascade');
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
// unique combi:
$table->unique(['tag_id', 'transaction_journal_id']);
}
);
// unique combi:
$table->unique(['tag_id', 'transaction_journal_id']);
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'tag_transaction_journal', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -589,16 +532,13 @@ class CreateMainTables extends Migration
if (!Schema::hasTable('budget_transaction_journal')) {
try {
Schema::create(
'budget_transaction_journal',
static function (Blueprint $table): void {
$table->increments('id');
$table->integer('budget_id', false, true);
$table->integer('transaction_journal_id', false, true);
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
}
);
Schema::create('budget_transaction_journal', static function (Blueprint $table): void {
$table->increments('id');
$table->integer('budget_id', false, true);
$table->integer('transaction_journal_id', false, true);
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'budget_transaction_journal', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -607,16 +547,13 @@ class CreateMainTables extends Migration
if (!Schema::hasTable('category_transaction_journal')) {
try {
Schema::create(
'category_transaction_journal',
static function (Blueprint $table): void {
$table->increments('id');
$table->integer('category_id', false, true);
$table->integer('transaction_journal_id', false, true);
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
}
);
Schema::create('category_transaction_journal', static function (Blueprint $table): void {
$table->increments('id');
$table->integer('category_id', false, true);
$table->integer('transaction_journal_id', false, true);
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'category_transaction_journal', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -625,20 +562,17 @@ class CreateMainTables extends Migration
if (!Schema::hasTable('piggy_bank_events')) {
try {
Schema::create(
'piggy_bank_events',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('piggy_bank_id', false, true);
$table->integer('transaction_journal_id', false, true)->nullable();
$table->date('date');
$table->decimal('amount', 32, 12);
Schema::create('piggy_bank_events', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('piggy_bank_id', false, true);
$table->integer('transaction_journal_id', false, true)->nullable();
$table->date('date');
$table->decimal('amount', 32, 12);
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('set null');
}
);
$table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade');
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('set null');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'piggy_bank_events', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -647,21 +581,18 @@ class CreateMainTables extends Migration
if (!Schema::hasTable('transactions')) {
try {
Schema::create(
'transactions',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('account_id', false, true);
$table->integer('transaction_journal_id', false, true);
$table->string('description', 1024)->nullable();
$table->decimal('amount', 32, 12);
Schema::create('transactions', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('account_id', false, true);
$table->integer('transaction_journal_id', false, true);
$table->string('description', 1024)->nullable();
$table->decimal('amount', 32, 12);
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
}
);
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'transactions', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -670,17 +601,14 @@ class CreateMainTables extends Migration
if (!Schema::hasTable('budget_transaction')) {
try {
Schema::create(
'budget_transaction',
static function (Blueprint $table): void {
$table->increments('id');
$table->integer('budget_id', false, true);
$table->integer('transaction_id', false, true);
Schema::create('budget_transaction', static function (Blueprint $table): void {
$table->increments('id');
$table->integer('budget_id', false, true);
$table->integer('transaction_id', false, true);
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
$table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade');
}
);
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
$table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'budget_transaction', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -689,17 +617,14 @@ class CreateMainTables extends Migration
if (!Schema::hasTable('category_transaction')) {
try {
Schema::create(
'category_transaction',
static function (Blueprint $table): void {
$table->increments('id');
$table->integer('category_id', false, true);
$table->integer('transaction_id', false, true);
Schema::create('category_transaction', static function (Blueprint $table): void {
$table->increments('id');
$table->integer('category_id', false, true);
$table->integer('transaction_id', false, true);
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
$table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade');
}
);
$table->foreign('category_id')->references('id')->on('categories')->onDelete('cascade');
$table->foreign('transaction_id')->references('id')->on('transactions')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'category_transaction', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);

View File

@@ -33,12 +33,16 @@ class ChangesFor3101 extends Migration
/**
* Reverse the migrations.
*/
public function down(): void {}
public function down(): void
{
}
/**
* Run the migrations.
*
* @SuppressWarnings("PHPMD.ShortMethodName")
*/
public function up(): void {}
public function up(): void
{
}
}

View File

@@ -39,7 +39,9 @@ class FixNullables extends Migration
/**
* Reverse the migrations.
*/
public function down(): void {}
public function down(): void
{
}
/**
* Run the migrations.
@@ -50,12 +52,9 @@ class FixNullables extends Migration
{
if (!Schema::hasColumn('rule_groups', 'description')) {
try {
Schema::table(
'rule_groups',
static function (Blueprint $table): void {
$table->text('description')->nullable()->change();
}
);
Schema::table('rule_groups', static function (Blueprint $table): void {
$table->text('description')->nullable()->change();
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_UPDATE_ERROR, 'rule_groups', $e->getMessage()));
app('log')->error(self::COLUMN_ALREADY_EXISTS);
@@ -64,12 +63,9 @@ class FixNullables extends Migration
if (!Schema::hasColumn('rules', 'description')) {
try {
Schema::table(
'rules',
static function (Blueprint $table): void {
$table->text('description')->nullable()->change();
}
);
Schema::table('rules', static function (Blueprint $table): void {
$table->text('description')->nullable()->change();
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_UPDATE_ERROR, 'rules', $e->getMessage()));
app('log')->error(self::COLUMN_ALREADY_EXISTS);

View File

@@ -40,12 +40,9 @@ class ExpandTransactionsTable extends Migration
{
if (Schema::hasColumn('transactions', 'identifier')) {
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
$table->dropColumn('identifier');
}
);
Schema::table('transactions', static function (Blueprint $table): void {
$table->dropColumn('identifier');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not drop column "identifier": %s', $e->getMessage()));
app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -62,12 +59,9 @@ class ExpandTransactionsTable extends Migration
{
if (!Schema::hasColumn('transactions', 'identifier')) {
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
$table->smallInteger('identifier', false, true)->default(0);
}
);
Schema::table('transactions', static function (Blueprint $table): void {
$table->smallInteger('identifier', false, true)->default(0);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -50,21 +50,20 @@ class ChangesForV410 extends Migration
{
if (!Schema::hasTable('notes')) {
try {
Schema::create(
'notes',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('noteable_id', false, true);
$table->string('noteable_type');
$table->string('title')->nullable();
$table->text('text')->nullable();
}
);
Schema::create('notes', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('noteable_id', false, true);
$table->string('noteable_type');
$table->string('title')->nullable();
$table->text('text')->nullable();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "notes": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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

@@ -40,12 +40,9 @@ class ChangesForV420 extends Migration
{
if (Schema::hasColumn('journal_meta', 'deleted_at')) {
try {
Schema::table(
'journal_meta',
static function (Blueprint $table): void {
$table->dropSoftDeletes();
}
);
Schema::table('journal_meta', static function (Blueprint $table): void {
$table->dropSoftDeletes();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -62,12 +59,9 @@ class ChangesForV420 extends Migration
{
if (!Schema::hasColumn('journal_meta', 'deleted_at')) {
try {
Schema::table(
'journal_meta',
static function (Blueprint $table): void {
$table->softDeletes();
}
);
Schema::table('journal_meta', static function (Blueprint $table): void {
$table->softDeletes();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -50,25 +50,24 @@ class ChangesForV430 extends Migration
{
if (!Schema::hasTable('available_budgets')) {
try {
Schema::create(
'available_budgets',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('transaction_currency_id', false, true);
$table->decimal('amount', 32, 12);
$table->date('start_date');
$table->date('end_date');
Schema::create('available_budgets', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('transaction_currency_id', false, true);
$table->decimal('amount', 32, 12);
$table->date('start_date');
$table->date('end_date');
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "available_budgets": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
}
}

View File

@@ -41,12 +41,9 @@ class ChangesForV431 extends Migration
// reinstate "repeats" and "repeat_freq".
if (!Schema::hasColumn('budget_limits', 'repeat_freq')) {
try {
Schema::table(
'budget_limits',
static function (Blueprint $table): void {
$table->string('repeat_freq', 30)->nullable();
}
);
Schema::table('budget_limits', static function (Blueprint $table): void {
$table->string('repeat_freq', 30)->nullable();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -54,12 +51,9 @@ class ChangesForV431 extends Migration
}
if (!Schema::hasColumn('budget_limits', 'repeats')) {
try {
Schema::table(
'budget_limits',
static function (Blueprint $table): void {
$table->boolean('repeats')->default(0);
}
);
Schema::table('budget_limits', static function (Blueprint $table): void {
$table->boolean('repeats')->default(0);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -68,12 +62,9 @@ class ChangesForV431 extends Migration
// change field "start_date" to "startdate"
if (Schema::hasColumn('budget_limits', 'start_date') && !Schema::hasColumn('budget_limits', 'startdate')) {
try {
Schema::table(
'budget_limits',
static function (Blueprint $table): void {
$table->renameColumn('start_date', 'startdate');
}
);
Schema::table('budget_limits', static function (Blueprint $table): void {
$table->renameColumn('start_date', 'startdate');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -83,12 +74,9 @@ class ChangesForV431 extends Migration
// remove date field "end_date"
if (Schema::hasColumn('budget_limits', 'end_date')) {
try {
Schema::table(
'budget_limits',
static function (Blueprint $table): void {
$table->dropColumn('end_date');
}
);
Schema::table('budget_limits', static function (Blueprint $table): void {
$table->dropColumn('end_date');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -97,12 +85,9 @@ class ChangesForV431 extends Migration
// remove decimal places
if (Schema::hasColumn('transaction_currencies', 'decimal_places')) {
try {
Schema::table(
'transaction_currencies',
static function (Blueprint $table): void {
$table->dropColumn('decimal_places');
}
);
Schema::table('transaction_currencies', static function (Blueprint $table): void {
$table->dropColumn('decimal_places');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -120,12 +105,9 @@ class ChangesForV431 extends Migration
// add decimal places to "transaction currencies".
if (!Schema::hasColumn('transaction_currencies', 'decimal_places')) {
try {
Schema::table(
'transaction_currencies',
static function (Blueprint $table): void {
$table->smallInteger('decimal_places', false, true)->default(2);
}
);
Schema::table('transaction_currencies', static function (Blueprint $table): void {
$table->smallInteger('decimal_places', false, true)->default(2);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -135,12 +117,9 @@ class ChangesForV431 extends Migration
// change field "startdate" to "start_date"
if (Schema::hasColumn('budget_limits', 'startdate') && !Schema::hasColumn('budget_limits', 'start_date')) {
try {
Schema::table(
'budget_limits',
static function (Blueprint $table): void {
$table->renameColumn('startdate', 'start_date');
}
);
Schema::table('budget_limits', static function (Blueprint $table): void {
$table->renameColumn('startdate', 'start_date');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -150,12 +129,9 @@ class ChangesForV431 extends Migration
// add date field "end_date" after "start_date"
if (!Schema::hasColumn('budget_limits', 'end_date')) {
try {
Schema::table(
'budget_limits',
static function (Blueprint $table): void {
$table->date('end_date')->nullable()->after('start_date');
}
);
Schema::table('budget_limits', static function (Blueprint $table): void {
$table->date('end_date')->nullable()->after('start_date');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -165,12 +141,9 @@ class ChangesForV431 extends Migration
// drop "repeats" and "repeat_freq".
if (Schema::hasColumn('budget_limits', 'repeats')) {
try {
Schema::table(
'budget_limits',
static function (Blueprint $table): void {
$table->dropColumn('repeats');
}
);
Schema::table('budget_limits', static function (Blueprint $table): void {
$table->dropColumn('repeats');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -178,12 +151,9 @@ class ChangesForV431 extends Migration
}
if (Schema::hasColumn('budget_limits', 'repeat_freq')) {
try {
Schema::table(
'budget_limits',
static function (Blueprint $table): void {
$table->dropColumn('repeat_freq');
}
);
Schema::table('budget_limits', static function (Blueprint $table): void {
$table->dropColumn('repeat_freq');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -41,18 +41,15 @@ class ChangesForV440 extends Migration
Schema::dropIfExists('currency_exchange_rates');
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
if (Schema::hasColumn('transactions', 'transaction_currency_id')) {
// cannot drop foreign keys in SQLite:
if ('sqlite' !== config('database.default')) {
$table->dropForeign('transactions_transaction_currency_id_foreign');
}
$table->dropColumn('transaction_currency_id');
Schema::table('transactions', static function (Blueprint $table): void {
if (Schema::hasColumn('transactions', 'transaction_currency_id')) {
// cannot drop foreign keys in SQLite:
if ('sqlite' !== config('database.default')) {
$table->dropForeign('transactions_transaction_currency_id_foreign');
}
$table->dropColumn('transaction_currency_id');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -68,40 +65,36 @@ class ChangesForV440 extends Migration
{
if (!Schema::hasTable('currency_exchange_rates')) {
try {
Schema::create(
'currency_exchange_rates',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('from_currency_id', false, true);
$table->integer('to_currency_id', false, true);
$table->date('date');
$table->decimal('rate', 32, 12);
$table->decimal('user_rate', 32, 12)->nullable();
Schema::create('currency_exchange_rates', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('from_currency_id', false, true);
$table->integer('to_currency_id', false, true);
$table->date('date');
$table->decimal('rate', 32, 12);
$table->decimal('user_rate', 32, 12)->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('from_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
$table->foreign('to_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
}
);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('from_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
$table->foreign('to_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "notifications": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
}
if (!Schema::hasColumn('transactions', 'transaction_currency_id')) {
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
if (!Schema::hasColumn('transactions', 'transaction_currency_id')) {
$table->integer('transaction_currency_id', false, true)->after('description')->nullable();
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
}
Schema::table('transactions', static function (Blueprint $table): void {
if (!Schema::hasColumn('transactions', 'transaction_currency_id')) {
$table->integer('transaction_currency_id', false, true)->after('description')->nullable();
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -41,12 +41,9 @@ class ChangesForV450 extends Migration
// split up for sqlite compatibility
if (Schema::hasColumn('transactions', 'foreign_amount')) {
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
$table->dropColumn('foreign_amount');
}
);
Schema::table('transactions', static function (Blueprint $table): void {
$table->dropColumn('foreign_amount');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -54,27 +51,21 @@ class ChangesForV450 extends Migration
}
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
// cannot drop foreign keys in SQLite:
if ('sqlite' !== config('database.default')) {
$table->dropForeign('transactions_foreign_currency_id_foreign');
}
Schema::table('transactions', static function (Blueprint $table): void {
// cannot drop foreign keys in SQLite:
if ('sqlite' !== config('database.default')) {
$table->dropForeign('transactions_foreign_currency_id_foreign');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
if (Schema::hasColumn('transactions', 'foreign_currency_id')) {
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
$table->dropColumn('foreign_currency_id');
}
);
Schema::table('transactions', static function (Blueprint $table): void {
$table->dropColumn('foreign_currency_id');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -92,12 +83,9 @@ class ChangesForV450 extends Migration
// add "foreign_amount" to transactions
if (!Schema::hasColumn('transactions', 'foreign_amount')) {
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
$table->decimal('foreign_amount', 32, 12)->nullable()->after('amount');
}
);
Schema::table('transactions', static function (Blueprint $table): void {
$table->decimal('foreign_amount', 32, 12)->nullable()->after('amount');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -107,13 +95,10 @@ class ChangesForV450 extends Migration
// add foreign transaction currency id to transactions (is nullable):
if (!Schema::hasColumn('transactions', 'foreign_currency_id')) {
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
$table->integer('foreign_currency_id', false, true)->default(null)->after('foreign_amount')->nullable();
$table->foreign('foreign_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
}
);
Schema::table('transactions', static function (Blueprint $table): void {
$table->integer('foreign_currency_id', false, true)->default(null)->after('foreign_amount')->nullable();
$table->foreign('foreign_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -51,48 +51,46 @@ class ChangesForV470 extends Migration
{
if (!Schema::hasTable('link_types')) {
try {
Schema::create(
'link_types',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->string('name');
$table->string('outward');
$table->string('inward');
$table->boolean('editable');
Schema::create('link_types', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->string('name');
$table->string('outward');
$table->string('inward');
$table->boolean('editable');
$table->unique(['name', 'outward', 'inward']);
}
);
$table->unique(['name', 'outward', 'inward']);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "link_types": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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): void {
$table->increments('id');
$table->timestamps();
$table->integer('link_type_id', false, true);
$table->integer('source_id', false, true);
$table->integer('destination_id', false, true);
$table->text('comment')->nullable();
Schema::create('journal_links', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->integer('link_type_id', false, true);
$table->integer('source_id', false, true);
$table->integer('destination_id', false, true);
$table->text('comment')->nullable();
$table->foreign('link_type_id')->references('id')->on('link_types')->onDelete('cascade');
$table->foreign('source_id')->references('id')->on('transaction_journals')->onDelete('cascade');
$table->foreign('destination_id')->references('id')->on('transaction_journals')->onDelete('cascade');
$table->foreign('link_type_id')->references('id')->on('link_types')->onDelete('cascade');
$table->foreign('source_id')->references('id')->on('transaction_journals')->onDelete('cascade');
$table->foreign('destination_id')->references('id')->on('transaction_journals')->onDelete('cascade');
$table->unique(['link_type_id', 'source_id', 'destination_id']);
}
);
$table->unique(['link_type_id', 'source_id', 'destination_id']);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "journal_links": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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

@@ -40,12 +40,9 @@ class ChangesForV470a extends Migration
{
if (Schema::hasColumn('transactions', 'reconciled')) {
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
$table->dropColumn('reconciled');
}
);
Schema::table('transactions', static function (Blueprint $table): void {
$table->dropColumn('reconciled');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -62,12 +59,9 @@ class ChangesForV470a extends Migration
{
if (!Schema::hasColumn('transactions', 'reconciled')) {
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
$table->boolean('reconciled')->after('deleted_at')->default(0);
}
);
Schema::table('transactions', static function (Blueprint $table): void {
$table->boolean('reconciled')->after('deleted_at')->default(0);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -51,20 +51,19 @@ class CreateOauthAuthCodesTable extends Migration
{
if (!Schema::hasTable('oauth_auth_codes')) {
try {
Schema::create(
'oauth_auth_codes',
static function (Blueprint $table): void {
$table->string('id', 100)->primary();
$table->integer('user_id');
$table->integer('client_id');
$table->text('scopes')->nullable();
$table->boolean('revoked');
$table->dateTime('expires_at')->nullable();
}
);
Schema::create('oauth_auth_codes', static function (Blueprint $table): void {
$table->string('id', 100)->primary();
$table->integer('user_id');
$table->integer('client_id');
$table->text('scopes')->nullable();
$table->boolean('revoked');
$table->dateTime('expires_at')->nullable();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "oauth_auth_codes": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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

@@ -51,22 +51,21 @@ class CreateOauthAccessTokensTable extends Migration
{
if (!Schema::hasTable('oauth_access_tokens')) {
try {
Schema::create(
'oauth_access_tokens',
static function (Blueprint $table): void {
$table->string('id', 100)->primary();
$table->integer('user_id')->index()->nullable();
$table->integer('client_id');
$table->string('name')->nullable();
$table->text('scopes')->nullable();
$table->boolean('revoked');
$table->timestamps();
$table->dateTime('expires_at')->nullable();
}
);
Schema::create('oauth_access_tokens', static function (Blueprint $table): void {
$table->string('id', 100)->primary();
$table->integer('user_id')->index()->nullable();
$table->integer('client_id');
$table->string('name')->nullable();
$table->text('scopes')->nullable();
$table->boolean('revoked');
$table->timestamps();
$table->dateTime('expires_at')->nullable();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "oauth_access_tokens": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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

@@ -51,18 +51,17 @@ class CreateOauthRefreshTokensTable extends Migration
{
if (!Schema::hasTable('oauth_refresh_tokens')) {
try {
Schema::create(
'oauth_refresh_tokens',
static function (Blueprint $table): void {
$table->string('id', 100)->primary();
$table->string('access_token_id', 100)->index();
$table->boolean('revoked');
$table->dateTime('expires_at')->nullable();
}
);
Schema::create('oauth_refresh_tokens', static function (Blueprint $table): void {
$table->string('id', 100)->primary();
$table->string('access_token_id', 100)->index();
$table->boolean('revoked');
$table->dateTime('expires_at')->nullable();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "oauth_refresh_tokens": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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

@@ -51,23 +51,22 @@ class CreateOauthClientsTable extends Migration
{
if (!Schema::hasTable('oauth_clients')) {
try {
Schema::create(
'oauth_clients',
static function (Blueprint $table): void {
$table->increments('id');
$table->integer('user_id')->index()->nullable();
$table->string('name');
$table->string('secret', 100);
$table->text('redirect');
$table->boolean('personal_access_client');
$table->boolean('password_client');
$table->boolean('revoked');
$table->timestamps();
}
);
Schema::create('oauth_clients', static function (Blueprint $table): void {
$table->increments('id');
$table->integer('user_id')->index()->nullable();
$table->string('name');
$table->string('secret', 100);
$table->text('redirect');
$table->boolean('personal_access_client');
$table->boolean('password_client');
$table->boolean('revoked');
$table->timestamps();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "oauth_clients": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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

@@ -51,17 +51,16 @@ class CreateOauthPersonalAccessClientsTable extends Migration
{
if (!Schema::hasTable('oauth_personal_access_clients')) {
try {
Schema::create(
'oauth_personal_access_clients',
static function (Blueprint $table): void {
$table->increments('id');
$table->integer('client_id')->index();
$table->timestamps();
}
);
Schema::create('oauth_personal_access_clients', static function (Blueprint $table): void {
$table->increments('id');
$table->integer('client_id')->index();
$table->timestamps();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "oauth_personal_access_clients": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
}
}

View File

@@ -41,12 +41,9 @@ class ChangesForV472 extends Migration
{
if (!Schema::hasColumn('attachments', 'notes')) {
try {
Schema::table(
'attachments',
static function (Blueprint $table): void {
$table->text('notes')->nullable();
}
);
Schema::table('attachments', static function (Blueprint $table): void {
$table->text('notes')->nullable();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -55,12 +52,9 @@ class ChangesForV472 extends Migration
if (Schema::hasColumn('transactions', 'order')) {
try {
Schema::table(
'budgets',
static function (Blueprint $table): void {
$table->dropColumn('order');
}
);
Schema::table('budgets', static function (Blueprint $table): void {
$table->dropColumn('order');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -77,12 +71,9 @@ class ChangesForV472 extends Migration
{
if (Schema::hasColumn('attachments', 'notes')) {
try {
Schema::table(
'attachments',
static function (Blueprint $table): void {
$table->dropColumn('notes');
}
);
Schema::table('attachments', static function (Blueprint $table): void {
$table->dropColumn('notes');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -91,12 +82,9 @@ class ChangesForV472 extends Migration
if (!Schema::hasColumn('budgets', 'order')) {
try {
Schema::table(
'budgets',
static function (Blueprint $table): void {
$table->mediumInteger('order', false, true)->default(0);
}
);
Schema::table('budgets', static function (Blueprint $table): void {
$table->mediumInteger('order', false, true)->default(0);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -41,16 +41,13 @@ class ChangesForV473 extends Migration
{
if (!Schema::hasColumn('bills', 'transaction_currency_id')) {
try {
Schema::table(
'bills',
static function (Blueprint $table): void {
// cannot drop foreign keys in SQLite:
if ('sqlite' !== config('database.default')) {
$table->dropForeign('bills_transaction_currency_id_foreign');
}
$table->dropColumn('transaction_currency_id');
Schema::table('bills', static function (Blueprint $table): void {
// cannot drop foreign keys in SQLite:
if ('sqlite' !== config('database.default')) {
$table->dropForeign('bills_transaction_currency_id_foreign');
}
);
$table->dropColumn('transaction_currency_id');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -59,12 +56,9 @@ class ChangesForV473 extends Migration
if (!Schema::hasColumn('rules', 'strict')) {
try {
Schema::table(
'rules',
static function (Blueprint $table): void {
$table->dropColumn('strict');
}
);
Schema::table('rules', static function (Blueprint $table): void {
$table->dropColumn('strict');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -81,13 +75,10 @@ class ChangesForV473 extends Migration
{
if (!Schema::hasColumn('bills', 'transaction_currency_id')) {
try {
Schema::table(
'bills',
static function (Blueprint $table): void {
$table->integer('transaction_currency_id', false, true)->nullable()->after('user_id');
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
}
);
Schema::table('bills', static function (Blueprint $table): void {
$table->integer('transaction_currency_id', false, true)->nullable()->after('user_id');
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -95,12 +86,9 @@ class ChangesForV473 extends Migration
}
if (!Schema::hasColumn('rules', 'strict')) {
try {
Schema::table(
'rules',
static function (Blueprint $table): void {
$table->boolean('strict')->default(true);
}
);
Schema::table('rules', static function (Blueprint $table): void {
$table->boolean('strict')->default(true);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -34,12 +34,16 @@ class ChangesForV474 extends Migration
/**
* Reverse the migrations.
*/
public function down(): void {}
public function down(): void
{
}
/**
* Run the migrations.
*
* @SuppressWarnings("PHPMD.ShortMethodName")
*/
public function up(): void {}
public function up(): void
{
}
}

View File

@@ -56,130 +56,125 @@ class ChangesForV475 extends Migration
{
if (!Schema::hasTable('recurrences')) {
try {
Schema::create(
'recurrences',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('transaction_type_id', false, true);
Schema::create('recurrences', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->integer('transaction_type_id', false, true);
$table->string('title', 1024);
$table->text('description');
$table->string('title', 1024);
$table->text('description');
$table->date('first_date');
$table->date('repeat_until')->nullable();
$table->date('latest_date')->nullable();
$table->smallInteger('repetitions', false, true);
$table->date('first_date');
$table->date('repeat_until')->nullable();
$table->date('latest_date')->nullable();
$table->smallInteger('repetitions', false, true);
$table->boolean('apply_rules')->default(true);
$table->boolean('active')->default(true);
$table->boolean('apply_rules')->default(true);
$table->boolean('active')->default(true);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');
}
);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->foreign('transaction_type_id')->references('id')->on('transaction_types')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "recurrences": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
}
if (!Schema::hasTable('recurrences_transactions')) {
try {
Schema::create(
'recurrences_transactions',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('recurrence_id', false, true);
$table->integer('transaction_currency_id', false, true);
$table->integer('foreign_currency_id', false, true)->nullable();
$table->integer('source_id', false, true);
$table->integer('destination_id', false, true);
Schema::create('recurrences_transactions', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('recurrence_id', false, true);
$table->integer('transaction_currency_id', false, true);
$table->integer('foreign_currency_id', false, true)->nullable();
$table->integer('source_id', false, true);
$table->integer('destination_id', false, true);
$table->decimal('amount', 32, 12);
$table->decimal('foreign_amount', 32, 12)->nullable();
$table->string('description', 1024);
$table->decimal('amount', 32, 12);
$table->decimal('foreign_amount', 32, 12)->nullable();
$table->string('description', 1024);
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
$table->foreign('foreign_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
$table->foreign('source_id')->references('id')->on('accounts')->onDelete('cascade');
$table->foreign('destination_id')->references('id')->on('accounts')->onDelete('cascade');
}
);
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
$table->foreign('foreign_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
$table->foreign('source_id')->references('id')->on('accounts')->onDelete('cascade');
$table->foreign('destination_id')->references('id')->on('accounts')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "recurrences_transactions": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
}
if (!Schema::hasTable('recurrences_repetitions')) {
try {
Schema::create(
'recurrences_repetitions',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('recurrence_id', false, true);
$table->string('repetition_type', 50);
$table->string('repetition_moment', 50);
$table->smallInteger('repetition_skip', false, true);
$table->smallInteger('weekend', false, true);
Schema::create('recurrences_repetitions', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('recurrence_id', false, true);
$table->string('repetition_type', 50);
$table->string('repetition_moment', 50);
$table->smallInteger('repetition_skip', false, true);
$table->smallInteger('weekend', false, true);
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
}
);
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "recurrences_repetitions": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
}
if (!Schema::hasTable('recurrences_meta')) {
try {
Schema::create(
'recurrences_meta',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('recurrence_id', false, true);
Schema::create('recurrences_meta', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('recurrence_id', false, true);
$table->string('name', 50);
$table->text('value');
$table->string('name', 50);
$table->text('value');
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
}
);
$table->foreign('recurrence_id')->references('id')->on('recurrences')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "recurrences_meta": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
}
if (!Schema::hasTable('rt_meta')) {
try {
Schema::create(
'rt_meta',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('rt_id', false, true);
Schema::create('rt_meta', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('rt_id', false, true);
$table->string('name', 50);
$table->text('value');
$table->string('name', 50);
$table->text('value');
$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) {
app('log')->error(sprintf('Could not create table "rt_meta": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
}
}

View File

@@ -41,17 +41,14 @@ class ChangesForV477 extends Migration
{
if (Schema::hasColumn('budget_limits', 'transaction_currency_id')) {
try {
Schema::table(
'budget_limits',
static function (Blueprint $table): void {
// cannot drop foreign keys in SQLite:
if ('sqlite' !== config('database.default')) {
$table->dropForeign('budget_limits_transaction_currency_id_foreign');
}
$table->dropColumn(['transaction_currency_id']);
Schema::table('budget_limits', static function (Blueprint $table): void {
// cannot drop foreign keys in SQLite:
if ('sqlite' !== config('database.default')) {
$table->dropForeign('budget_limits_transaction_currency_id_foreign');
}
);
$table->dropColumn(['transaction_currency_id']);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -68,13 +65,10 @@ class ChangesForV477 extends Migration
{
if (!Schema::hasColumn('budget_limits', 'transaction_currency_id')) {
try {
Schema::table(
'budget_limits',
static function (Blueprint $table): void {
$table->integer('transaction_currency_id', false, true)->nullable()->after('budget_id');
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
}
);
Schema::table('budget_limits', static function (Blueprint $table): void {
$table->integer('transaction_currency_id', false, true)->nullable()->after('budget_id');
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('set null');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -41,12 +41,9 @@ class ChangesForV479 extends Migration
{
if (Schema::hasColumn('transaction_currencies', 'enabled')) {
try {
Schema::table(
'transaction_currencies',
static function (Blueprint $table): void {
$table->dropColumn(['enabled']);
}
);
Schema::table('transaction_currencies', static function (Blueprint $table): void {
$table->dropColumn(['enabled']);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -63,12 +60,9 @@ class ChangesForV479 extends Migration
{
if (!Schema::hasColumn('transaction_currencies', 'enabled')) {
try {
Schema::table(
'transaction_currencies',
static function (Blueprint $table): void {
$table->boolean('enabled')->default(0)->after('deleted_at');
}
);
Schema::table('transaction_currencies', static function (Blueprint $table): void {
$table->boolean('enabled')->default(0)->after('deleted_at');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -52,43 +52,41 @@ class ChangesForV4710 extends Migration
{
if (!Schema::hasTable('transaction_groups')) {
try {
Schema::create(
'transaction_groups',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('title', 1024)->nullable();
Schema::create('transaction_groups', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('title', 1024)->nullable();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "transaction_groups": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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): void {
$table->increments('id');
$table->integer('transaction_group_id', false, true);
$table->integer('transaction_journal_id', false, true);
Schema::create('group_journals', static function (Blueprint $table): void {
$table->increments('id');
$table->integer('transaction_group_id', false, true);
$table->integer('transaction_journal_id', false, true);
$table->foreign('transaction_group_id')->references('id')->on('transaction_groups')->onDelete('cascade');
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
$table->foreign('transaction_group_id')->references('id')->on('transaction_groups')->onDelete('cascade');
$table->foreign('transaction_journal_id')->references('id')->on('transaction_journals')->onDelete('cascade');
// unique combi:
$table->unique(['transaction_group_id', 'transaction_journal_id'], 'unique_in_group');
}
);
// unique combi:
$table->unique(['transaction_group_id', 'transaction_journal_id'], 'unique_in_group');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "group_journals": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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,9 @@ class ChangesForV4711 extends Migration
/**
* Reverse the migrations.
*/
public function down(): void {}
public function down(): void
{
}
/**
* Run the migrations.
@@ -55,24 +57,18 @@ class ChangesForV4711 extends Migration
* nice.
*/
try {
Schema::table(
'transaction_journals',
static function (Blueprint $table): void {
$table->dateTime('date')->change();
}
);
Schema::table('transaction_journals', static function (Blueprint $table): void {
$table->dateTime('date')->change();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
try {
Schema::table(
'preferences',
static function (Blueprint $table): void {
$table->text('data')->nullable()->change();
}
);
Schema::table('preferences', static function (Blueprint $table): void {
$table->text('data')->nullable()->change();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -37,7 +37,9 @@ class ChangesForV4712 extends Migration
/**
* Reverse the migrations.
*/
public function down(): void {}
public function down(): void
{
}
/**
* Run the migrations.
@@ -55,12 +57,9 @@ class ChangesForV4712 extends Migration
* nice.
*/
try {
Schema::table(
'transaction_journals',
static function (Blueprint $table): void {
$table->dateTime('date')->change();
}
);
Schema::table('transaction_journals', static function (Blueprint $table): void {
$table->dateTime('date')->change();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -41,12 +41,9 @@ class FixLdapConfiguration extends Migration
{
if (Schema::hasColumn('users', 'objectguid')) {
try {
Schema::table(
'users',
static function (Blueprint $table): void {
$table->dropColumn(['objectguid']);
}
);
Schema::table('users', static function (Blueprint $table): void {
$table->dropColumn(['objectguid']);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -67,12 +64,9 @@ class FixLdapConfiguration extends Migration
*/
if (!Schema::hasColumn('users', 'objectguid')) {
try {
Schema::table(
'users',
static function (Blueprint $table): void {
$table->uuid('objectguid')->nullable()->after('id');
}
);
Schema::table('users', static function (Blueprint $table): void {
$table->uuid('objectguid')->nullable()->after('id');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -42,28 +42,27 @@ class ChangesForV480 extends Migration
// remove group ID
if (Schema::hasColumn('transaction_journals', 'transaction_group_id')) {
try {
Schema::table(
'transaction_journals',
static function (Blueprint $table): void {
// drop transaction_group_id + foreign key.
// cannot drop foreign keys in SQLite:
if ('sqlite' !== config('database.default')) {
try {
$table->dropForeign('transaction_journals_transaction_group_id_foreign');
} catch (QueryException $e) {
app('log')->error(sprintf('Could not drop foreign ID: %s', $e->getMessage()));
app('log')->error('If the foreign ID does not exist (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
}
Schema::table('transaction_journals', static function (Blueprint $table): void {
// drop transaction_group_id + foreign key.
// cannot drop foreign keys in SQLite:
if ('sqlite' !== config('database.default')) {
try {
$table->dropColumn('transaction_group_id');
$table->dropForeign('transaction_journals_transaction_group_id_foreign');
} catch (QueryException $e) {
app('log')->error(sprintf('Could not drop column: %s', $e->getMessage()));
app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
app('log')->error(sprintf('Could not drop foreign ID: %s', $e->getMessage()));
app('log')->error(
'If the foreign ID does not exist (see error), this is not an problem. Otherwise, please open a GitHub discussion.'
);
}
}
);
try {
$table->dropColumn('transaction_group_id');
} catch (QueryException $e) {
app('log')->error(sprintf('Could not drop column: %s', $e->getMessage()));
app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -73,17 +72,14 @@ class ChangesForV480 extends Migration
// remove 'stop processing' column
if (Schema::hasColumn('rule_groups', 'stop_processing')) {
try {
Schema::table(
'rule_groups',
static function (Blueprint $table): void {
try {
$table->dropColumn('stop_processing');
} catch (QueryException $e) {
app('log')->error(sprintf('Could not drop column: %s', $e->getMessage()));
app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}
Schema::table('rule_groups', static function (Blueprint $table): void {
try {
$table->dropColumn('stop_processing');
} catch (QueryException $e) {
app('log')->error(sprintf('Could not drop column: %s', $e->getMessage()));
app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -93,17 +89,14 @@ class ChangesForV480 extends Migration
// remove 'mfa_secret' column
if (Schema::hasColumn('users', 'mfa_secret')) {
try {
Schema::table(
'users',
static function (Blueprint $table): void {
try {
$table->dropColumn('mfa_secret');
} catch (QueryException $e) {
app('log')->error(sprintf('Could not drop column: %s', $e->getMessage()));
app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}
Schema::table('users', static function (Blueprint $table): void {
try {
$table->dropColumn('mfa_secret');
} catch (QueryException $e) {
app('log')->error(sprintf('Could not drop column: %s', $e->getMessage()));
app('log')->error('If the column does not exist, this is not an problem. Otherwise, please open a GitHub discussion.');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -121,27 +114,22 @@ class ChangesForV480 extends Migration
// add currency_id
if (!Schema::hasColumn('transaction_journals', 'transaction_group_id')) {
try {
Schema::table(
'transaction_journals',
static function (Blueprint $table): void {
$table->integer('transaction_currency_id', false, true)->nullable()->change();
Schema::table('transaction_journals', static function (Blueprint $table): void {
$table->integer('transaction_currency_id', false, true)->nullable()->change();
// add column "group_id" after "transaction_type_id"
$table->integer('transaction_group_id', false, true)
->nullable()->default(null)->after('transaction_type_id')
;
// add column "group_id" after "transaction_type_id"
$table->integer('transaction_group_id', false, true)->nullable()->default(null)->after('transaction_type_id');
// add foreign key for "transaction_group_id"
try {
$table->foreign('transaction_group_id')->references('id')->on('transaction_groups')->onDelete('cascade');
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create foreign index: %s', $e->getMessage()));
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
// add foreign key for "transaction_group_id"
try {
$table->foreign('transaction_group_id')->references('id')->on('transaction_groups')->onDelete('cascade');
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create foreign index: %s', $e->getMessage()));
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -151,12 +139,9 @@ class ChangesForV480 extends Migration
// add 'stop processing' column
if (!Schema::hasColumn('rule_groups', 'stop_processing')) {
try {
Schema::table(
'rule_groups',
static function (Blueprint $table): void {
$table->boolean('stop_processing')->default(false);
}
);
Schema::table('rule_groups', static function (Blueprint $table): void {
$table->boolean('stop_processing')->default(false);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -166,12 +151,9 @@ class ChangesForV480 extends Migration
// add 'mfa_secret' column
if (!Schema::hasColumn('users', 'mfa_secret')) {
try {
Schema::table(
'users',
static function (Blueprint $table): void {
$table->string('mfa_secret', 50)->nullable();
}
);
Schema::table('users', static function (Blueprint $table): void {
$table->string('mfa_secret', 50)->nullable();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -51,24 +51,23 @@ class MakeLocationsTable extends Migration
{
if (!Schema::hasTable('locations')) {
try {
Schema::create(
'locations',
static function (Blueprint $table): void {
$table->bigIncrements('id');
$table->timestamps();
$table->softDeletes();
Schema::create('locations', static function (Blueprint $table): void {
$table->bigIncrements('id');
$table->timestamps();
$table->softDeletes();
$table->integer('locatable_id', false, true);
$table->string('locatable_type', 255);
$table->integer('locatable_id', false, true);
$table->string('locatable_type', 255);
$table->decimal('latitude', 12, 8)->nullable();
$table->decimal('longitude', 12, 8)->nullable();
$table->smallInteger('zoom_level', false, true)->nullable();
}
);
$table->decimal('latitude', 12, 8)->nullable();
$table->decimal('longitude', 12, 8)->nullable();
$table->smallInteger('zoom_level', false, true)->nullable();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "locations": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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

@@ -52,25 +52,24 @@ class ChangesForV520 extends Migration
{
if (!Schema::hasTable('auto_budgets')) {
try {
Schema::create(
'auto_budgets',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('budget_id', false, true);
$table->integer('transaction_currency_id', false, true);
$table->tinyInteger('auto_budget_type', false, true)->default(1);
$table->decimal('amount', 32, 12);
$table->string('period', 50);
Schema::create('auto_budgets', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('budget_id', false, true);
$table->integer('transaction_currency_id', false, true);
$table->tinyInteger('auto_budget_type', false, true)->default(1);
$table->decimal('amount', 32, 12);
$table->string('period', 50);
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
}
);
$table->foreign('transaction_currency_id')->references('id')->on('transaction_currencies')->onDelete('cascade');
$table->foreign('budget_id')->references('id')->on('budgets')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "auto_budgets": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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

@@ -52,37 +52,35 @@ class ChangesForV530 extends Migration
{
if (!Schema::hasTable('object_groups')) {
try {
Schema::create(
'object_groups',
static function (Blueprint $table): void {
$table->increments('id');
$table->integer('user_id', false, true);
$table->timestamps();
$table->softDeletes();
$table->string('title', 255);
$table->mediumInteger('order', false, true)->default(0);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
Schema::create('object_groups', static function (Blueprint $table): void {
$table->increments('id');
$table->integer('user_id', false, true);
$table->timestamps();
$table->softDeletes();
$table->string('title', 255);
$table->mediumInteger('order', false, true)->default(0);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "object_groups": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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): void {
$table->integer('object_group_id');
$table->integer('object_groupable_id', false, true);
$table->string('object_groupable_type', 255);
}
);
Schema::create('object_groupables', static function (Blueprint $table): void {
$table->integer('object_group_id');
$table->integer('object_groupable_id', false, true);
$table->string('object_groupable_type', 255);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "object_groupables": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
}
}

View File

@@ -41,12 +41,9 @@ class ChangesForV530a extends Migration
{
if (Schema::hasColumn('bills', 'order')) {
try {
Schema::table(
'bills',
static function (Blueprint $table): void {
$table->dropColumn('order');
}
);
Schema::table('bills', static function (Blueprint $table): void {
$table->dropColumn('order');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -63,12 +60,9 @@ class ChangesForV530a extends Migration
{
if (!Schema::hasColumn('bills', 'order')) {
try {
Schema::table(
'bills',
static function (Blueprint $table): void {
$table->integer('order', false, true)->default(0);
}
);
Schema::table('bills', static function (Blueprint $table): void {
$table->integer('order', false, true)->default(0);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -41,12 +41,9 @@ class ChangesForV540 extends Migration
{
if (Schema::hasColumn('oauth_clients', 'provider')) {
try {
Schema::table(
'oauth_clients',
static function (Blueprint $table): void {
$table->dropColumn('provider');
}
);
Schema::table('oauth_clients', static function (Blueprint $table): void {
$table->dropColumn('provider');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -55,12 +52,9 @@ class ChangesForV540 extends Migration
if (Schema::hasColumn('accounts', 'order')) {
try {
Schema::table(
'accounts',
static function (Blueprint $table): void {
$table->dropColumn('order');
}
);
Schema::table('accounts', static function (Blueprint $table): void {
$table->dropColumn('order');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -69,12 +63,9 @@ class ChangesForV540 extends Migration
// in two steps for sqlite
if (Schema::hasColumn('bills', 'end_date')) {
try {
Schema::table(
'bills',
static function (Blueprint $table): void {
$table->dropColumn('end_date');
}
);
Schema::table('bills', static function (Blueprint $table): void {
$table->dropColumn('end_date');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -82,12 +73,9 @@ class ChangesForV540 extends Migration
}
if (Schema::hasColumn('bills', 'extension_date')) {
try {
Schema::table(
'bills',
static function (Blueprint $table): void {
$table->dropColumn('extension_date');
}
);
Schema::table('bills', static function (Blueprint $table): void {
$table->dropColumn('extension_date');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -104,12 +92,9 @@ class ChangesForV540 extends Migration
{
if (!Schema::hasColumn('accounts', 'order')) {
try {
Schema::table(
'accounts',
static function (Blueprint $table): void {
$table->integer('order', false, true)->default(0);
}
);
Schema::table('accounts', static function (Blueprint $table): void {
$table->integer('order', false, true)->default(0);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -118,12 +103,9 @@ class ChangesForV540 extends Migration
if (!Schema::hasColumn('oauth_clients', 'provider')) {
try {
Schema::table(
'oauth_clients',
static function (Blueprint $table): void {
$table->string('provider')->nullable();
}
);
Schema::table('oauth_clients', static function (Blueprint $table): void {
$table->string('provider')->nullable();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -132,13 +114,10 @@ class ChangesForV540 extends Migration
if (!Schema::hasColumn('bills', 'end_date') && !Schema::hasColumn('bills', 'extension_date')) {
try {
Schema::table(
'bills',
static function (Blueprint $table): void {
$table->date('end_date')->nullable()->after('date');
$table->date('extension_date')->nullable()->after('end_date');
}
);
Schema::table('bills', static function (Blueprint $table): void {
$table->date('end_date')->nullable()->after('date');
$table->date('extension_date')->nullable()->after('end_date');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -147,12 +126,9 @@ class ChangesForV540 extends Migration
// make column nullable:
try {
Schema::table(
'oauth_clients',
static function (Blueprint $table): void {
$table->string('secret', 100)->nullable()->change();
}
);
Schema::table('oauth_clients', static function (Blueprint $table): void {
$table->string('secret', 100)->nullable()->change();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -42,39 +42,35 @@ class ChangesForV550 extends Migration
if (!Schema::hasTable('jobs')) {
try {
Schema::create(
'jobs',
static function (Blueprint $table): void {
// straight from Laravel (this is the OLD table)
$table->bigIncrements('id');
$table->string('queue');
$table->longText('payload');
$table->tinyInteger('attempts')->unsigned();
$table->tinyInteger('reserved')->unsigned();
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
$table->index(['queue', 'reserved', 'reserved_at']);
}
);
Schema::create('jobs', static function (Blueprint $table): void {
// straight from Laravel (this is the OLD table)
$table->bigIncrements('id');
$table->string('queue');
$table->longText('payload');
$table->tinyInteger('attempts')->unsigned();
$table->tinyInteger('reserved')->unsigned();
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
$table->index(['queue', 'reserved', 'reserved_at']);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "jobs": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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.
if (Schema::hasColumn('budget_transaction_journal', 'budget_limit_id')) {
try {
Schema::table(
'budget_transaction_journal',
static function (Blueprint $table): void {
if ('sqlite' !== config('database.default')) {
$table->dropForeign('budget_id_foreign');
}
$table->dropColumn('budget_limit_id');
Schema::table('budget_transaction_journal', static function (Blueprint $table): void {
if ('sqlite' !== config('database.default')) {
$table->dropForeign('budget_id_foreign');
}
);
$table->dropColumn('budget_limit_id');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -88,12 +84,9 @@ class ChangesForV550 extends Migration
// in two steps for sqlite
if (Schema::hasColumn('budget_limits', 'period')) {
try {
Schema::table(
'budget_limits',
static function (Blueprint $table): void {
$table->dropColumn('period');
}
);
Schema::table('budget_limits', static function (Blueprint $table): void {
$table->dropColumn('period');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -101,12 +94,9 @@ class ChangesForV550 extends Migration
}
if (Schema::hasColumn('budget_limits', 'generated')) {
try {
Schema::table(
'budget_limits',
static function (Blueprint $table): void {
$table->dropColumn('generated');
}
);
Schema::table('budget_limits', static function (Blueprint $table): void {
$table->dropColumn('generated');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -133,21 +123,20 @@ class ChangesForV550 extends Migration
// this is the NEW table
if (!Schema::hasTable('jobs')) {
try {
Schema::create(
'jobs',
static function (Blueprint $table): void {
$table->bigIncrements('id');
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
}
);
Schema::create('jobs', static function (Blueprint $table): void {
$table->bigIncrements('id');
$table->string('queue')->index();
$table->longText('payload');
$table->unsignedTinyInteger('attempts');
$table->unsignedInteger('reserved_at')->nullable();
$table->unsignedInteger('available_at');
$table->unsignedInteger('created_at');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "jobs": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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.
@@ -156,36 +145,32 @@ class ChangesForV550 extends Migration
// create new failed_jobs table.
if (!Schema::hasTable('failed_jobs')) {
try {
Schema::create(
'failed_jobs',
static function (Blueprint $table): void {
$table->bigIncrements('id');
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
}
);
Schema::create('failed_jobs', static function (Blueprint $table): void {
$table->bigIncrements('id');
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
$table->longText('exception');
$table->timestamp('failed_at')->useCurrent();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "failed_jobs": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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.
if (!Schema::hasColumn('budget_transaction_journal', 'budget_limit_id')) {
try {
Schema::table(
'budget_transaction_journal',
static function (Blueprint $table): void {
if (!Schema::hasColumn('budget_transaction_journal', 'budget_limit_id')) {
$table->integer('budget_limit_id', false, true)->nullable()->default(null)->after('budget_id');
$table->foreign('budget_limit_id', 'budget_id_foreign')->references('id')->on('budget_limits')->onDelete('set null');
}
Schema::table('budget_transaction_journal', static function (Blueprint $table): void {
if (!Schema::hasColumn('budget_transaction_journal', 'budget_limit_id')) {
$table->integer('budget_limit_id', false, true)->nullable()->default(null)->after('budget_id');
$table->foreign('budget_limit_id', 'budget_id_foreign')->references('id')->on('budget_limits')->onDelete('set null');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -196,17 +181,14 @@ class ChangesForV550 extends Migration
// I swear I dropped & recreated this field 15 times already.
try {
Schema::table(
'budget_limits',
static function (Blueprint $table): void {
if (!Schema::hasColumn('budget_limits', 'period')) {
$table->string('period', 12)->nullable();
}
if (!Schema::hasColumn('budget_limits', 'generated')) {
$table->boolean('generated')->default(false);
}
Schema::table('budget_limits', static function (Blueprint $table): void {
if (!Schema::hasColumn('budget_limits', 'period')) {
$table->string('period', 12)->nullable();
}
);
if (!Schema::hasColumn('budget_limits', 'generated')) {
$table->boolean('generated')->default(false);
}
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -215,74 +197,71 @@ class ChangesForV550 extends Migration
// new webhooks table
if (!Schema::hasTable('webhooks')) {
try {
Schema::create(
'webhooks',
static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('title', 255)->index();
$table->string('secret', 32)->index();
$table->boolean('active')->default(true);
$table->unsignedSmallInteger('trigger');
$table->unsignedSmallInteger('response');
$table->unsignedSmallInteger('delivery');
$table->string('url', 1024);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
}
);
Schema::create('webhooks', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->string('title', 255)->index();
$table->string('secret', 32)->index();
$table->boolean('active')->default(true);
$table->unsignedSmallInteger('trigger');
$table->unsignedSmallInteger('response');
$table->unsignedSmallInteger('delivery');
$table->string('url', 1024);
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "webhooks": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->boolean('sent')->default(false);
$table->boolean('errored')->default(false);
Schema::create('webhook_messages', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->boolean('sent')->default(false);
$table->boolean('errored')->default(false);
$table->integer('webhook_id', false, true);
$table->string('uuid', 64);
$table->longText('message');
$table->integer('webhook_id', false, true);
$table->string('uuid', 64);
$table->longText('message');
$table->foreign('webhook_id')->references('id')->on('webhooks')->onDelete('cascade');
}
);
$table->foreign('webhook_id')->references('id')->on('webhooks')->onDelete('cascade');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "webhook_messages": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('webhook_message_id', false, true);
$table->unsignedSmallInteger('status_code')->default(0);
Schema::create('webhook_attempts', static function (Blueprint $table): void {
$table->increments('id');
$table->timestamps();
$table->softDeletes();
$table->integer('webhook_message_id', false, true);
$table->unsignedSmallInteger('status_code')->default(0);
$table->longText('logs')->nullable();
$table->longText('response')->nullable();
$table->longText('logs')->nullable();
$table->longText('response')->nullable();
$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) {
app('log')->error(sprintf('Could not create table "webhook_attempts": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
}
}

View File

@@ -39,17 +39,14 @@ class ChangesForV550b2 extends Migration
{
if (Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {
try {
Schema::table(
'recurrences_transactions',
static function (Blueprint $table): void {
if ('sqlite' !== config('database.default')) {
$table->dropForeign('type_foreign');
}
if (Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {
$table->dropColumn('transaction_type_id');
}
Schema::table('recurrences_transactions', static function (Blueprint $table): void {
if ('sqlite' !== config('database.default')) {
$table->dropForeign('type_foreign');
}
);
if (Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {
$table->dropColumn('transaction_type_id');
}
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -67,15 +64,12 @@ class ChangesForV550b2 extends Migration
// expand recurrence transaction table
if (!Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {
try {
Schema::table(
'recurrences_transactions',
static function (Blueprint $table): void {
if (!Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {
$table->integer('transaction_type_id', false, true)->nullable()->after('transaction_currency_id');
$table->foreign('transaction_type_id', 'type_foreign')->references('id')->on('transaction_types')->onDelete('set null');
}
Schema::table('recurrences_transactions', static function (Blueprint $table): void {
if (!Schema::hasColumn('recurrences_transactions', 'transaction_type_id')) {
$table->integer('transaction_type_id', false, true)->nullable()->after('transaction_currency_id');
$table->foreign('transaction_type_id', 'type_foreign')->references('id')->on('transaction_types')->onDelete('set null');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -36,12 +36,9 @@ class AddLdapColumnsToUsersTable extends Migration
{
if (Schema::hasColumn('users', 'domain')) {
try {
Schema::table(
'users',
static function (Blueprint $table): void {
$table->dropColumn(['domain']);
}
);
Schema::table('users', static function (Blueprint $table): void {
$table->dropColumn(['domain']);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -58,12 +55,9 @@ class AddLdapColumnsToUsersTable extends Migration
{
if (!Schema::hasColumn('users', 'domain')) {
try {
Schema::table(
'users',
static function (Blueprint $table): void {
$table->string('domain')->nullable();
}
);
Schema::table('users', static function (Blueprint $table): void {
$table->string('domain')->nullable();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -35,7 +35,9 @@ class ExtendCurrencyInfo extends Migration
/**
* Reverse the migrations.
*/
public function down(): void {}
public function down(): void
{
}
/**
* Run the migrations.
@@ -45,13 +47,10 @@ class ExtendCurrencyInfo extends Migration
public function up(): void
{
try {
Schema::table(
'transaction_currencies',
static function (Blueprint $table): void {
$table->string('code', 51)->change();
$table->string('symbol', 51)->change();
}
);
Schema::table('transaction_currencies', static function (Blueprint $table): void {
$table->string('code', 51)->change();
$table->string('symbol', 51)->change();
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -32,24 +32,23 @@ use Illuminate\Support\Facades\Schema;
*/
class UserGroups extends Migration
{
private array $tables
= [
'accounts',
'attachments',
'available_budgets',
'bills',
'budgets',
'categories',
'recurrences',
'object_groups',
'preferences',
'rule_groups',
'rules',
'tags',
'transaction_groups',
'transaction_journals',
'webhooks',
];
private array $tables = [
'accounts',
'attachments',
'available_budgets',
'bills',
'budgets',
'categories',
'recurrences',
'object_groups',
'preferences',
'rule_groups',
'rules',
'tags',
'transaction_groups',
'transaction_journals',
'webhooks'
];
/**
* Reverse the migrations.
@@ -61,17 +60,14 @@ class UserGroups extends Migration
foreach ($this->tables as $tableName) {
if (Schema::hasColumn($tableName, 'user_group_id')) {
try {
Schema::table(
$tableName,
static function (Blueprint $table) use ($tableName): void {
if ('sqlite' !== config('database.default')) {
$table->dropForeign(sprintf('%s_to_ugi', $tableName));
}
if (Schema::hasColumn($tableName, 'user_group_id')) {
$table->dropColumn('user_group_id');
}
Schema::table($tableName, static function (Blueprint $table) use ($tableName): void {
if ('sqlite' !== config('database.default')) {
$table->dropForeign(sprintf('%s_to_ugi', $tableName));
}
);
if (Schema::hasColumn($tableName, 'user_group_id')) {
$table->dropColumn('user_group_id');
}
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -81,17 +77,14 @@ class UserGroups extends Migration
if (Schema::hasColumn('users', 'user_group_id')) {
try {
Schema::table(
'users',
static function (Blueprint $table): void {
if ('sqlite' !== config('database.default')) {
$table->dropForeign('type_user_group_id');
}
if (Schema::hasColumn('users', 'user_group_id')) {
$table->dropColumn('user_group_id');
}
Schema::table('users', static function (Blueprint $table): void {
if ('sqlite' !== config('database.default')) {
$table->dropForeign('type_user_group_id');
}
);
if (Schema::hasColumn('users', 'user_group_id')) {
$table->dropColumn('user_group_id');
}
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -117,76 +110,68 @@ class UserGroups extends Migration
*/
if (!Schema::hasTable('user_groups')) {
try {
Schema::create(
'user_groups',
static function (Blueprint $table): void {
$table->bigIncrements('id');
$table->timestamps();
$table->softDeletes();
Schema::create('user_groups', static function (Blueprint $table): void {
$table->bigIncrements('id');
$table->timestamps();
$table->softDeletes();
$table->string('title', 255);
$table->unique('title');
}
);
$table->string('title', 255);
$table->unique('title');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "user_groups": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
}
if (!Schema::hasTable('user_roles')) {
try {
Schema::create(
'user_roles',
static function (Blueprint $table): void {
$table->bigIncrements('id');
$table->timestamps();
$table->softDeletes();
Schema::create('user_roles', static function (Blueprint $table): void {
$table->bigIncrements('id');
$table->timestamps();
$table->softDeletes();
$table->string('title', 255);
$table->unique('title');
}
);
$table->string('title', 255);
$table->unique('title');
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "user_roles": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
}
if (!Schema::hasTable('group_memberships')) {
try {
Schema::create(
'group_memberships',
static function (Blueprint $table): void {
$table->bigIncrements('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->bigInteger('user_group_id', false, true);
$table->bigInteger('user_role_id', false, true);
Schema::create('group_memberships', static function (Blueprint $table): void {
$table->bigIncrements('id');
$table->timestamps();
$table->softDeletes();
$table->integer('user_id', false, true);
$table->bigInteger('user_group_id', false, true);
$table->bigInteger('user_role_id', false, true);
$table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('user_group_id')->references('id')->on('user_groups')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('user_role_id')->references('id')->on('user_roles')->onUpdate('cascade')->onDelete('cascade');
$table->unique(['user_id', 'user_group_id', 'user_role_id']);
}
);
$table->foreign('user_id')->references('id')->on('users')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('user_group_id')->references('id')->on('user_groups')->onUpdate('cascade')->onDelete('cascade');
$table->foreign('user_role_id')->references('id')->on('user_roles')->onUpdate('cascade')->onDelete('cascade');
$table->unique(['user_id', 'user_group_id', 'user_role_id']);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "group_memberships": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
}
try {
Schema::table(
'users',
static function (Blueprint $table): void {
if (!Schema::hasColumn('users', 'user_group_id')) {
$table->bigInteger('user_group_id', false, true)->nullable();
$table->foreign('user_group_id', 'type_user_group_id')->references('id')->on('user_groups')->onDelete('set null')->onUpdate(
'cascade'
);
}
Schema::table('users', static function (Blueprint $table): void {
if (!Schema::hasColumn('users', 'user_group_id')) {
$table->bigInteger('user_group_id', false, true)->nullable();
$table->foreign('user_group_id', 'type_user_group_id')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -196,17 +181,17 @@ class UserGroups extends Migration
/** @var string $tableName */
foreach ($this->tables as $tableName) {
try {
Schema::table(
$tableName,
static function (Blueprint $table) use ($tableName): void {
if (!Schema::hasColumn($tableName, 'user_group_id')) {
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
$table->foreign('user_group_id', sprintf('%s_to_ugi', $tableName))->references('id')->on('user_groups')->onDelete(
'set null'
)->onUpdate('cascade');
}
Schema::table($tableName, static function (Blueprint $table) use ($tableName): void {
if (!Schema::hasColumn($tableName, 'user_group_id')) {
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
$table
->foreign('user_group_id', sprintf('%s_to_ugi', $tableName))
->references('id')
->on('user_groups')
->onDelete('set null')
->onUpdate('cascade');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -60,7 +60,9 @@ class CreateLocalPersonalAccessTokensTable extends Migration
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "personal_access_tokens": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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

@@ -27,7 +27,7 @@ use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
return new class() extends Migration {
/**
* Run the migrations.
*
@@ -36,15 +36,12 @@ return new class () extends Migration {
public function up(): void
{
try {
Schema::table(
'currency_exchange_rates',
static function (Blueprint $table): void {
if (!Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
$table->foreign('user_group_id', 'cer_to_ugi')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');
}
Schema::table('currency_exchange_rates', static function (Blueprint $table): void {
if (!Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
$table->foreign('user_group_id', 'cer_to_ugi')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -57,17 +54,14 @@ return new class () extends Migration {
public function down(): void
{
try {
Schema::table(
'currency_exchange_rates',
static function (Blueprint $table): void {
if ('sqlite' !== config('database.default')) {
$table->dropForeign('cer_to_ugi');
}
if (Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
$table->dropColumn('user_group_id');
}
Schema::table('currency_exchange_rates', static function (Blueprint $table): void {
if ('sqlite' !== config('database.default')) {
$table->dropForeign('cer_to_ugi');
}
);
if (Schema::hasColumn('currency_exchange_rates', 'user_group_id')) {
$table->dropColumn('user_group_id');
}
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -27,7 +27,7 @@ use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
return new class() extends Migration {
/**
* Run the migrations.
*
@@ -47,7 +47,9 @@ return new class () extends Migration {
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "notifications": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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

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

@@ -27,7 +27,7 @@ use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
return new class() extends Migration {
/**
* Run the migrations.
*
@@ -54,7 +54,9 @@ return new class () extends Migration {
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "audit_log_entries": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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

@@ -27,7 +27,7 @@ use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
return new class() extends Migration {
/**
* Run the migrations.
*
@@ -36,17 +36,17 @@ return new class () extends Migration {
public function up(): void
{
try {
Schema::table(
'object_groups',
static function (Blueprint $table): void {
if (!Schema::hasColumn('object_groups', 'user_group_id')) {
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
$table->foreign('user_group_id', sprintf('%s_to_ugi', 'object_groups'))->references('id')->on('user_groups')->onDelete(
'set null'
)->onUpdate('cascade');
}
Schema::table('object_groups', static function (Blueprint $table): void {
if (!Schema::hasColumn('object_groups', 'user_group_id')) {
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
$table
->foreign('user_group_id', sprintf('%s_to_ugi', 'object_groups'))
->references('id')
->on('user_groups')
->onDelete('set null')
->onUpdate('cascade');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -59,17 +59,14 @@ return new class () extends Migration {
public function down(): void
{
try {
Schema::table(
'object_groups',
static function (Blueprint $table): void {
if ('sqlite' !== config('database.default')) {
$table->dropForeign(sprintf('%s_to_ugi', 'object_groups'));
}
if (Schema::hasColumn('object_groups', 'user_group_id')) {
$table->dropColumn('user_group_id');
}
Schema::table('object_groups', static function (Blueprint $table): void {
if ('sqlite' !== config('database.default')) {
$table->dropForeign(sprintf('%s_to_ugi', 'object_groups'));
}
);
if (Schema::hasColumn('object_groups', 'user_group_id')) {
$table->dropColumn('user_group_id');
}
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -27,7 +27,7 @@ use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
return new class() extends Migration {
/**
* @SuppressWarnings("PHPMD.ShortMethodName")
* Run the migrations.
@@ -49,7 +49,9 @@ return new class () extends Migration {
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "transaction_currency_user": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('log')->error(
'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.'
);
}
}
@@ -68,7 +70,9 @@ return new class () extends Migration {
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not create table "transaction_currency_user_group": %s', $e->getMessage()));
app('log')->error('If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.');
app('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

@@ -1,6 +1,5 @@
<?php
/*
* 2024_03_03_174645_add_indices.php
* Copyright (c) 2025 james@firefly-iii.org.
@@ -28,7 +27,7 @@ use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
return new class() extends Migration {
private const string QUERY_ERROR = 'Could not execute query (table "%s", field "%s"): %s';
private const string EXPL = 'If the index already exists (see error), or if MySQL can\'t do it, this is not an problem. Otherwise, please open a GitHub discussion.';
@@ -46,19 +45,24 @@ return new class () extends Migration {
'category_transaction_journal' => ['transaction_journal_id'],
'categories' => ['user_id', 'user_group_id'],
'transaction_groups' => ['user_id', 'user_group_id'],
'transaction_journals' => ['user_id', 'user_group_id', 'date', 'transaction_group_id', 'transaction_type_id', 'transaction_currency_id', 'bill_id'],
'transactions' => ['account_id', 'transaction_journal_id', 'transaction_currency_id', 'foreign_currency_id'],
'transaction_journals' => [
'user_id',
'user_group_id',
'date',
'transaction_group_id',
'transaction_type_id',
'transaction_currency_id',
'bill_id'
],
'transactions' => ['account_id', 'transaction_journal_id', 'transaction_currency_id', 'foreign_currency_id']
];
foreach ($set as $table => $fields) {
foreach ($fields as $field) {
try {
Schema::table(
$table,
static function (Blueprint $blueprint) use ($field): void {
$blueprint->index($field);
}
);
Schema::table($table, static function (Blueprint $blueprint) use ($field): void {
$blueprint->index($field);
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::QUERY_ERROR, $table, $field, $e->getMessage()));
app('log')->error(self::EXPL);
@@ -70,5 +74,7 @@ return new class () extends Migration {
/**
* Reverse the migrations.
*/
public function down(): void {}
public function down(): void
{
}
};

View File

@@ -1,6 +1,5 @@
<?php
/*
* 2024_04_01_174351_expand_preferences_table.php
* Copyright (c) 2025 james@firefly-iii.org.
@@ -28,22 +27,19 @@ use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
return new class() extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
try {
Schema::table(
'preferences',
static function (Blueprint $table): void {
if (!Schema::hasColumn('preferences', 'user_group_id')) {
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
$table->foreign('user_group_id', 'preferences_to_ugi')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');
}
Schema::table('preferences', static function (Blueprint $table): void {
if (!Schema::hasColumn('preferences', 'user_group_id')) {
$table->bigInteger('user_group_id', false, true)->nullable()->after('user_id');
$table->foreign('user_group_id', 'preferences_to_ugi')->references('id')->on('user_groups')->onDelete('set null')->onUpdate('cascade');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -53,5 +49,7 @@ return new class () extends Migration {
/**
* Reverse the migrations.
*/
public function down(): void {}
public function down(): void
{
}
};

View File

@@ -1,6 +1,5 @@
<?php
/*
* 2024_05_12_060551_create_account_balance_table.php
* Copyright (c) 2025 james@firefly-iii.org.
@@ -27,7 +26,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
return new class() extends Migration {
/**
* Run the migrations.
*/

View File

@@ -1,6 +1,5 @@
<?php
/*
* 2024_07_28_145631_add_running_balance.php
* Copyright (c) 2025 james@firefly-iii.org.
@@ -28,49 +27,40 @@ use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
return new class() extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
if (!Schema::hasColumn('transactions', 'balance_before')) {
$table->decimal('balance_before', 32, 12)->nullable()->after('amount');
}
Schema::table('transactions', static function (Blueprint $table): void {
if (!Schema::hasColumn('transactions', 'balance_before')) {
$table->decimal('balance_before', 32, 12)->nullable()->after('amount');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
if (!Schema::hasColumn('transactions', 'balance_after')) {
$table->decimal('balance_after', 32, 12)->nullable()->after('balance_before');
}
Schema::table('transactions', static function (Blueprint $table): void {
if (!Schema::hasColumn('transactions', 'balance_after')) {
$table->decimal('balance_after', 32, 12)->nullable()->after('balance_before');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
if (!Schema::hasColumn('transactions', 'balance_dirty')) {
$table->boolean('balance_dirty')->default(true)->after('balance_after');
}
Schema::table('transactions', static function (Blueprint $table): void {
if (!Schema::hasColumn('transactions', 'balance_dirty')) {
$table->boolean('balance_dirty')->default(true)->after('balance_after');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
@@ -83,42 +73,33 @@ return new class () extends Migration {
public function down(): void
{
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
if (Schema::hasColumn('transactions', 'balance_before')) {
$table->dropColumn('balance_before');
}
Schema::table('transactions', static function (Blueprint $table): void {
if (Schema::hasColumn('transactions', 'balance_before')) {
$table->dropColumn('balance_before');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
if (Schema::hasColumn('transactions', 'balance_after')) {
$table->dropColumn('balance_after');
}
Schema::table('transactions', static function (Blueprint $table): void {
if (Schema::hasColumn('transactions', 'balance_after')) {
$table->dropColumn('balance_after');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
}
try {
Schema::table(
'transactions',
static function (Blueprint $table): void {
if (Schema::hasColumn('transactions', 'balance_dirty')) {
$table->dropColumn('balance_dirty');
}
Schema::table('transactions', static function (Blueprint $table): void {
if (Schema::hasColumn('transactions', 'balance_dirty')) {
$table->dropColumn('balance_dirty');
}
);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not execute query: %s', $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');

View File

@@ -1,6 +1,5 @@
<?php
/*
* 2024_11_05_062108_add_date_tz_columns.php
* Copyright (c) 2025 james@firefly-iii.org.
@@ -28,24 +27,24 @@ use Illuminate\Database\QueryException;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
return new class() extends Migration {
private array $tables;
public function __construct()
{
$this->tables = [
'account_balances' => ['date'], // done
'available_budgets' => ['start_date', 'end_date'], // done
'bills' => ['date', 'end_date', 'extension_date'], // done
'budget_limits' => ['start_date', 'end_date'], // done
'account_balances' => ['date'], // done
'available_budgets' => ['start_date', 'end_date'], // done
'bills' => ['date', 'end_date', 'extension_date'], // done
'budget_limits' => ['start_date', 'end_date'], // done
'currency_exchange_rates' => ['date'], // done
'invited_users' => ['expires'],
'piggy_bank_events' => ['date'],
'piggy_bank_repetitions' => ['startdate', 'targetdate'],
'piggy_banks' => ['startdate', 'targetdate'], // done
'recurrences' => ['first_date', 'repeat_until', 'latest_date'],
'tags' => ['date'],
'transaction_journals' => ['date'],
'invited_users' => ['expires'],
'piggy_bank_events' => ['date'],
'piggy_bank_repetitions' => ['startdate', 'targetdate'],
'piggy_banks' => ['startdate', 'targetdate'], // done
'recurrences' => ['first_date', 'repeat_until', 'latest_date'],
'tags' => ['date'],
'transaction_journals' => ['date']
];
}
@@ -60,15 +59,14 @@ return new class () extends Migration {
$newColumn = sprintf('%s_tz', $column);
if (Schema::hasColumn($table, $column) && !Schema::hasColumn($table, $newColumn)) {
try {
Schema::table(
$table,
static function (Blueprint $table) use ($column, $newColumn): void {
$table->string($newColumn, 50)->nullable()->after($column);
}
);
Schema::table($table, static function (Blueprint $table) use ($column, $newColumn): void {
$table->string($newColumn, 50)->nullable()->after($column);
});
} catch (QueryException $e) {
app('log')->error(sprintf('Could not add column "%s" to table "%s" query: %s', $newColumn, $table, $e->getMessage()));
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
app('log')->error(
'If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.'
);
}
}
}
@@ -78,5 +76,7 @@ return new class () extends Migration {
/**
* Reverse the migrations.
*/
public function down(): void {}
public function down(): void
{
}
};

View File

@@ -1,6 +1,5 @@
<?php
/*
* 2024_11_30_075826_multi_piggy.php
* Copyright (c) 2025 james@firefly-iii.org.
@@ -28,7 +27,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.
*/
@@ -114,7 +113,6 @@ return new class () extends Migration {
$table->unique(['account_id', 'piggy_bank_id'], 'unique_piggy_save');
});
}
}
/**
@@ -161,7 +159,6 @@ return new class () extends Migration {
protected static function hasForeign(string $table, string $column): bool
{
$foreignKeysDefinitions = Schema::getForeignKeys($table);
foreach ($foreignKeysDefinitions as $foreignKeyDefinition) {
if ($foreignKeyDefinition['name'] === $column) {

View File

@@ -1,6 +1,5 @@
<?php
/*
* 2024_12_19_061003_add_native_amount_column.php
* Copyright (c) 2025 james@firefly-iii.org.
@@ -27,21 +26,19 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class () extends Migration {
private array $tables
= [
// !!! this array is also in PreferencesEventHandler + RecalculateNativeAmountsCommand
'accounts' => ['native_virtual_balance'], // works.
'account_piggy_bank' => ['native_current_amount'], // works
'auto_budgets' => ['native_amount'], // works
'available_budgets' => ['native_amount'], // works
'bills' => ['native_amount_min', 'native_amount_max'], // works
'budget_limits' => ['native_amount'], // works
'piggy_bank_events' => ['native_amount'], // works
'piggy_banks' => ['native_target_amount'], // works
'transactions' => ['native_amount', 'native_foreign_amount'], // works
];
return new class() extends Migration {
private array $tables = [
// !!! this array is also in PreferencesEventHandler + RecalculateNativeAmountsCommand
'accounts' => ['native_virtual_balance'], // works.
'account_piggy_bank' => ['native_current_amount'], // works
'auto_budgets' => ['native_amount'], // works
'available_budgets' => ['native_amount'], // works
'bills' => ['native_amount_min', 'native_amount_max'], // works
'budget_limits' => ['native_amount'], // works
'piggy_bank_events' => ['native_amount'], // works
'piggy_banks' => ['native_target_amount'], // works
'transactions' => ['native_amount', 'native_foreign_amount'] // works
];
/**
* Run the migrations.

View File

@@ -1,6 +1,5 @@
<?php
/*
* 2025_07_10_065736_rename_tag_mode.php
* Copyright (c) 2025 james@firefly-iii.org

View File

@@ -1,6 +1,5 @@
<?php
/*
* 2025_08_19_180459_create_webhook_details_tables.php
* Copyright (c) 2025 james@firefly-iii.org
@@ -66,42 +65,35 @@ return new class extends Migration {
// webhook_webhook_trigger
if (!Schema::hasTable('webhook_webhook_trigger')) {
try {
Schema::create(
'webhook_webhook_trigger',
static function (Blueprint $table): void {
$table->increments('id');
$table->integer('webhook_id', false, true);
$table->bigInteger('webhook_trigger_id', false, true);
$table->foreign('webhook_id')->references('id')->on('webhooks')->onDelete('cascade');
$table->foreign('webhook_trigger_id','link_to_trigger')->references('id')->on('webhook_triggers')->onDelete('cascade');
Schema::create('webhook_webhook_trigger', static function (Blueprint $table): void {
$table->increments('id');
$table->integer('webhook_id', false, true);
$table->bigInteger('webhook_trigger_id', false, true);
$table->foreign('webhook_id')->references('id')->on('webhooks')->onDelete('cascade');
$table->foreign('webhook_trigger_id', 'link_to_trigger')->references('id')->on('webhook_triggers')->onDelete('cascade');
// unique combi:
$table->unique(['webhook_id', 'webhook_trigger_id']);
}
);
// unique combi:
$table->unique(['webhook_id', 'webhook_trigger_id']);
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'webhook_webhook_trigger', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
}
}
// webhook_webhook_response
if (!Schema::hasTable('webhook_webhook_response')) {
try {
Schema::create(
'webhook_webhook_response',
static function (Blueprint $table): void {
$table->increments('id');
$table->integer('webhook_id', false, true);
$table->bigInteger('webhook_response_id', false, true);
$table->foreign('webhook_id')->references('id')->on('webhooks')->onDelete('cascade');
$table->foreign('webhook_response_id','link_to_response')->references('id')->on('webhook_responses')->onDelete('cascade');
Schema::create('webhook_webhook_response', static function (Blueprint $table): void {
$table->increments('id');
$table->integer('webhook_id', false, true);
$table->bigInteger('webhook_response_id', false, true);
$table->foreign('webhook_id')->references('id')->on('webhooks')->onDelete('cascade');
$table->foreign('webhook_response_id', 'link_to_response')->references('id')->on('webhook_responses')->onDelete('cascade');
// unique combi:
$table->unique(['webhook_id', 'webhook_response_id']);
}
);
// unique combi:
$table->unique(['webhook_id', 'webhook_response_id']);
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'webhook_webhook_response', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
@@ -111,25 +103,21 @@ return new class extends Migration {
// webhook_webhook_delivery
if (!Schema::hasTable('webhook_webhook_delivery')) {
try {
Schema::create(
'webhook_webhook_delivery',
static function (Blueprint $table): void {
$table->increments('id');
$table->integer('webhook_id', false, true);
$table->bigInteger('webhook_delivery_id', false, true);
$table->foreign('webhook_id')->references('id')->on('webhooks')->onDelete('cascade');
$table->foreign('webhook_delivery_id','link_to_delivery')->references('id')->on('webhook_deliveries')->onDelete('cascade');
Schema::create('webhook_webhook_delivery', static function (Blueprint $table): void {
$table->increments('id');
$table->integer('webhook_id', false, true);
$table->bigInteger('webhook_delivery_id', false, true);
$table->foreign('webhook_id')->references('id')->on('webhooks')->onDelete('cascade');
$table->foreign('webhook_delivery_id', 'link_to_delivery')->references('id')->on('webhook_deliveries')->onDelete('cascade');
// unique combi:
$table->unique(['webhook_id', 'webhook_delivery_id']);
}
);
// unique combi:
$table->unique(['webhook_id', 'webhook_delivery_id']);
});
} catch (QueryException $e) {
app('log')->error(sprintf(self::TABLE_ERROR, 'webhook_webhook_delivery', $e->getMessage()));
app('log')->error(self::TABLE_ALREADY_EXISTS);
}
}
}
/**

View File

@@ -4,8 +4,7 @@ use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
return new class extends Migration {
/**
* Run the migrations.
*/

View File

@@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
/**
* Fixes #11620
*/
return new class extends Migration {
public function up(): void
{
Schema::table('transactions', static function (Blueprint $blueprint): void {
$blueprint->index(['transaction_journal_id', 'amount'], 'idx_tx_journal_amount');
});
Schema::table('tag_transaction_journal', static function (Blueprint $blueprint): void {
$blueprint->index(['transaction_journal_id', 'tag_id'], 'idx_ttj_journal_tag');
});
Schema::table('transaction_journals', static function (Blueprint $blueprint): void {
$blueprint->index(['deleted_at'], 'idx_tj_deleted');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};

View File

@@ -4,7 +4,7 @@ php-version = "8.4.0"
[source]
workspace = "."
paths = ["app/", "database/factories/", "database/seeders/", "tests/", "resources/lang/en_US"]
paths = ["app/", "database/factories/", "database/migrations/", "database/seeders/", "tests/", "resources/lang/en_US"]
includes = ["vendor"]
excludes = []