mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2026-08-19 01:14:43 -05:00
🤖 Auto commit for release 'develop' on 2026-02-06
This commit is contained in:
@@ -91,6 +91,24 @@ class CreateSupportTables extends Migration
|
||||
}
|
||||
}
|
||||
|
||||
private function createConfigurationTable(): void
|
||||
{
|
||||
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');
|
||||
});
|
||||
} catch (QueryException $e) {
|
||||
app('log')->error(sprintf(self::TABLE_ERROR, 'configuration', $e->getMessage()));
|
||||
app('log')->error(self::TABLE_ALREADY_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function createCurrencyTable(): void
|
||||
{
|
||||
if (!Schema::hasTable('transaction_currencies')) {
|
||||
@@ -113,26 +131,6 @@ class CreateSupportTables extends Migration
|
||||
}
|
||||
}
|
||||
|
||||
private function createTransactionTypeTable(): void
|
||||
{
|
||||
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);
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function createJobsTable(): void
|
||||
{
|
||||
if (!Schema::hasTable('jobs')) {
|
||||
@@ -173,6 +171,26 @@ class CreateSupportTables extends Migration
|
||||
}
|
||||
}
|
||||
|
||||
private function createPermissionRoleTable(): void
|
||||
{
|
||||
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();
|
||||
|
||||
$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']);
|
||||
});
|
||||
} catch (QueryException $e) {
|
||||
app('log')->error(sprintf(self::TABLE_ERROR, 'permission_role', $e->getMessage()));
|
||||
app('log')->error(self::TABLE_ALREADY_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function createPermissionsTable(): void
|
||||
{
|
||||
if (!Schema::hasTable('permissions')) {
|
||||
@@ -209,26 +227,6 @@ class CreateSupportTables extends Migration
|
||||
}
|
||||
}
|
||||
|
||||
private function createPermissionRoleTable(): void
|
||||
{
|
||||
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();
|
||||
|
||||
$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']);
|
||||
});
|
||||
} catch (QueryException $e) {
|
||||
app('log')->error(sprintf(self::TABLE_ERROR, 'permission_role', $e->getMessage()));
|
||||
app('log')->error(self::TABLE_ALREADY_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function createSessionsTable(): void
|
||||
{
|
||||
if (!Schema::hasTable('sessions')) {
|
||||
@@ -248,19 +246,21 @@ class CreateSupportTables extends Migration
|
||||
}
|
||||
}
|
||||
|
||||
private function createConfigurationTable(): void
|
||||
private function createTransactionTypeTable(): void
|
||||
{
|
||||
if (!Schema::hasTable('configuration')) {
|
||||
if (!Schema::hasTable('transaction_types')) {
|
||||
try {
|
||||
Schema::create('configuration', static function (Blueprint $table): void {
|
||||
Schema::create('transaction_types', static function (Blueprint $table): void {
|
||||
$table->increments('id');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
$table->string('name', 50);
|
||||
$table->text('data');
|
||||
$table->string('type', 50);
|
||||
|
||||
// type must be unique.
|
||||
$table->unique(['type']);
|
||||
});
|
||||
} catch (QueryException $e) {
|
||||
app('log')->error(sprintf(self::TABLE_ERROR, 'configuration', $e->getMessage()));
|
||||
app('log')->error(sprintf(self::TABLE_ERROR, 'transaction_types', $e->getMessage()));
|
||||
app('log')->error(self::TABLE_ALREADY_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,48 +132,6 @@ class CreateMainTables extends Migration
|
||||
}
|
||||
}
|
||||
|
||||
private function createPiggyBanksTable(): void
|
||||
{
|
||||
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');
|
||||
});
|
||||
} catch (QueryException $e) {
|
||||
app('log')->error(sprintf(self::TABLE_ERROR, 'piggy_banks', $e->getMessage()));
|
||||
app('log')->error(self::TABLE_ALREADY_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
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');
|
||||
});
|
||||
} catch (QueryException $e) {
|
||||
app('log')->error(sprintf(self::TABLE_ERROR, 'piggy_bank_repetitions', $e->getMessage()));
|
||||
app('log')->error(self::TABLE_ALREADY_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function createAttachmentsTable(): void
|
||||
{
|
||||
if (!Schema::hasTable('attachments')) {
|
||||
@@ -295,6 +253,48 @@ class CreateMainTables extends Migration
|
||||
}
|
||||
}
|
||||
|
||||
private function createPiggyBanksTable(): void
|
||||
{
|
||||
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');
|
||||
});
|
||||
} catch (QueryException $e) {
|
||||
app('log')->error(sprintf(self::TABLE_ERROR, 'piggy_banks', $e->getMessage()));
|
||||
app('log')->error(self::TABLE_ALREADY_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
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');
|
||||
});
|
||||
} catch (QueryException $e) {
|
||||
app('log')->error(sprintf(self::TABLE_ERROR, 'piggy_bank_repetitions', $e->getMessage()));
|
||||
app('log')->error(self::TABLE_ALREADY_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function createPreferencesTable(): void
|
||||
{
|
||||
if (!Schema::hasTable('preferences')) {
|
||||
|
||||
@@ -28,26 +28,6 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class() extends Migration {
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @SuppressWarnings("PHPMD.ShortMethodName")
|
||||
*/
|
||||
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');
|
||||
}
|
||||
});
|
||||
} 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.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
@@ -67,4 +47,24 @@ return new class() extends Migration {
|
||||
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @SuppressWarnings("PHPMD.ShortMethodName")
|
||||
*/
|
||||
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');
|
||||
}
|
||||
});
|
||||
} 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.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,6 +28,14 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class() extends Migration {
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('notifications');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
@@ -53,12 +61,4 @@ return new class() extends Migration {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('notifications');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,6 +28,14 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class() extends Migration {
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('invited_users');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
@@ -55,12 +63,4 @@ return new class() extends Migration {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('invited_users');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,6 +28,14 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class() extends Migration {
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('audit_log_entries');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
@@ -60,12 +68,4 @@ return new class() extends Migration {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('audit_log_entries');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,6 +28,26 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class() extends Migration {
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
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');
|
||||
}
|
||||
});
|
||||
} 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.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
@@ -52,24 +72,4 @@ return new class() extends Migration {
|
||||
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
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');
|
||||
}
|
||||
});
|
||||
} 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.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,6 +28,15 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class() extends Migration {
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('transaction_currency_user');
|
||||
Schema::dropIfExists('transaction_currency_user_group');
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.ShortMethodName")
|
||||
* Run the migrations.
|
||||
@@ -76,13 +85,4 @@ return new class() extends Migration {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('transaction_currency_user');
|
||||
Schema::dropIfExists('transaction_currency_user_group');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -31,6 +31,13 @@ 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.';
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
@@ -70,11 +77,4 @@ return new class() extends Migration {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,6 +28,13 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class() extends Migration {
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
@@ -45,11 +52,4 @@ return new class() extends Migration {
|
||||
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@@ -27,6 +27,14 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class() extends Migration {
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('account_balances');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
@@ -50,12 +58,4 @@ return new class() extends Migration {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('account_balances');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,45 +28,6 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
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');
|
||||
}
|
||||
});
|
||||
} 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');
|
||||
}
|
||||
});
|
||||
} 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');
|
||||
}
|
||||
});
|
||||
} 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.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
@@ -105,4 +66,43 @@ return new class() extends Migration {
|
||||
app('log')->error('If the column or index already exists (see error), this is not an problem. Otherwise, please open a GitHub discussion.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
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');
|
||||
}
|
||||
});
|
||||
} 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');
|
||||
}
|
||||
});
|
||||
} 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');
|
||||
}
|
||||
});
|
||||
} 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.');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -48,6 +48,13 @@ return new class() extends Migration {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
* TODO journal_meta, all date fields?
|
||||
@@ -72,11 +79,4 @@ return new class() extends Migration {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@@ -28,6 +28,60 @@ use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
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) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('piggy_banks', static function (Blueprint $table): void {
|
||||
// 1. drop account index again.
|
||||
$table->dropForeign('piggy_banks_account_id_foreign');
|
||||
|
||||
// rename columns again.
|
||||
$table->renameColumn('target_amount', 'targetamount');
|
||||
$table->renameColumn('start_date', 'startdate');
|
||||
$table->renameColumn('target_date', 'targetdate');
|
||||
$table->renameColumn('start_date_tz', 'startdate_tz');
|
||||
$table->renameColumn('target_date_tz', 'targetdate_tz');
|
||||
|
||||
// 3. drop currency again + index
|
||||
if (self::hasForeign('piggy_banks', 'unique_currency')) {
|
||||
$table->dropForeign('unique_currency');
|
||||
}
|
||||
$table->dropColumn('transaction_currency_id');
|
||||
|
||||
// 2. make column non-nullable.
|
||||
$table->unsignedInteger('account_id')->nullable()->change();
|
||||
|
||||
// 5. add new index
|
||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
});
|
||||
|
||||
// rename some fields in piggy bank reps.
|
||||
Schema::table('piggy_bank_repetitions', static function (Blueprint $table): void {
|
||||
// 6. rename columns
|
||||
$table->renameColumn('current_amount', 'currentamount');
|
||||
$table->renameColumn('start_date', 'startdate');
|
||||
$table->renameColumn('target_date', 'targetdate');
|
||||
$table->renameColumn('start_date_tz', 'startdate_tz');
|
||||
$table->renameColumn('target_date_tz', 'targetdate_tz');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('account_piggy_bank');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
@@ -114,58 +168,4 @@ return new class() extends Migration {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('piggy_banks', static function (Blueprint $table): void {
|
||||
// 1. drop account index again.
|
||||
$table->dropForeign('piggy_banks_account_id_foreign');
|
||||
|
||||
// rename columns again.
|
||||
$table->renameColumn('target_amount', 'targetamount');
|
||||
$table->renameColumn('start_date', 'startdate');
|
||||
$table->renameColumn('target_date', 'targetdate');
|
||||
$table->renameColumn('start_date_tz', 'startdate_tz');
|
||||
$table->renameColumn('target_date_tz', 'targetdate_tz');
|
||||
|
||||
// 3. drop currency again + index
|
||||
if (self::hasForeign('piggy_banks', 'unique_currency')) {
|
||||
$table->dropForeign('unique_currency');
|
||||
}
|
||||
$table->dropColumn('transaction_currency_id');
|
||||
|
||||
// 2. make column non-nullable.
|
||||
$table->unsignedInteger('account_id')->nullable()->change();
|
||||
|
||||
// 5. add new index
|
||||
$table->foreign('account_id')->references('id')->on('accounts')->onDelete('cascade');
|
||||
});
|
||||
|
||||
// rename some fields in piggy bank reps.
|
||||
Schema::table('piggy_bank_repetitions', static function (Blueprint $table): void {
|
||||
// 6. rename columns
|
||||
$table->renameColumn('current_amount', 'currentamount');
|
||||
$table->renameColumn('start_date', 'startdate');
|
||||
$table->renameColumn('target_date', 'targetdate');
|
||||
$table->renameColumn('start_date_tz', 'startdate_tz');
|
||||
$table->renameColumn('target_date_tz', 'targetdate_tz');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('account_piggy_bank');
|
||||
}
|
||||
|
||||
protected static function hasForeign(string $table, string $column): bool
|
||||
{
|
||||
$foreignKeysDefinitions = Schema::getForeignKeys($table);
|
||||
foreach ($foreignKeysDefinitions as $foreignKeyDefinition) {
|
||||
if ($foreignKeyDefinition['name'] === $column) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -40,6 +40,21 @@ return new class() extends Migration {
|
||||
'transactions' => ['native_amount', 'native_foreign_amount'] // works
|
||||
];
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
foreach ($this->tables as $table => $fields) {
|
||||
foreach ($fields as $field) {
|
||||
Schema::table($table, static function (Blueprint $table) use ($field): void {
|
||||
// add amount column
|
||||
$table->dropColumn($field);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
@@ -56,19 +71,4 @@ return new class() extends Migration {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
foreach ($this->tables as $table => $fields) {
|
||||
foreach ($fields as $field) {
|
||||
Schema::table($table, static function (Blueprint $table) use ($field): void {
|
||||
// add amount column
|
||||
$table->dropColumn($field);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -26,6 +26,22 @@ use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
try {
|
||||
Schema::table('tags', static function (Blueprint $table): void {
|
||||
if (Schema::hasColumn('tags', 'tag_mode') && !Schema::hasColumn('piggy_banks', 'tagMode')) {
|
||||
$table->renameColumn('tag_mode', 'tagMode');
|
||||
}
|
||||
});
|
||||
} catch (RuntimeException $e) {
|
||||
Log::error(sprintf('Could not rename column: %s', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
@@ -48,20 +64,4 @@ return new class extends Migration {
|
||||
Log::error(sprintf('Could not rename column: %s', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
try {
|
||||
Schema::table('tags', static function (Blueprint $table): void {
|
||||
if (Schema::hasColumn('tags', 'tag_mode') && !Schema::hasColumn('piggy_banks', 'tagMode')) {
|
||||
$table->renameColumn('tag_mode', 'tagMode');
|
||||
}
|
||||
});
|
||||
} catch (RuntimeException $e) {
|
||||
Log::error(sprintf('Could not rename column: %s', $e->getMessage()));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -29,6 +29,20 @@ return new class extends Migration {
|
||||
private const TABLE_ALREADY_EXISTS = 'If this table exists already (see the error message), this is not a problem. Other errors? Please open a discussion on GitHub.';
|
||||
private const TABLE_ERROR = 'Could not create table "%s": %s';
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('webhook_webhook_delivery');
|
||||
Schema::dropIfExists('webhook_webhook_trigger');
|
||||
Schema::dropIfExists('webhook_webhook_response');
|
||||
|
||||
Schema::dropIfExists('webhook_triggers');
|
||||
Schema::dropIfExists('webhook_responses');
|
||||
Schema::dropIfExists('webhook_deliveries');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
@@ -119,18 +133,4 @@ return new class extends Migration {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('webhook_webhook_delivery');
|
||||
Schema::dropIfExists('webhook_webhook_trigger');
|
||||
Schema::dropIfExists('webhook_webhook_response');
|
||||
|
||||
Schema::dropIfExists('webhook_triggers');
|
||||
Schema::dropIfExists('webhook_responses');
|
||||
Schema::dropIfExists('webhook_deliveries');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,6 +5,14 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('period_statistics');
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
@@ -41,12 +49,4 @@ return new class extends Migration {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('period_statistics');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -8,6 +8,14 @@ use Illuminate\Support\Facades\Schema;
|
||||
* Fixes #11620
|
||||
*/
|
||||
return new class extends Migration {
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('transactions', static function (Blueprint $blueprint): void {
|
||||
@@ -21,12 +29,4 @@ return new class extends Migration {
|
||||
$blueprint->index(['deleted_at'], 'idx_tj_deleted');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
};
|
||||
|
||||
@@ -71,16 +71,6 @@ class ExchangeRateSeeder extends Seeder
|
||||
}
|
||||
}
|
||||
|
||||
private function getCurrency(string $code): null|TransactionCurrency
|
||||
{
|
||||
return TransactionCurrency::whereNull('deleted_at')->where('code', $code)->first();
|
||||
}
|
||||
|
||||
private function hasRate(User $user, TransactionCurrency $from, TransactionCurrency $to, string $date): bool
|
||||
{
|
||||
return $user->currencyExchangeRates()->where('from_currency_id', $from->id)->where('to_currency_id', $to->id)->where('date', $date)->count() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @SuppressWarnings("PHPMD.ExcessiveParameterList")
|
||||
*/
|
||||
@@ -95,4 +85,14 @@ class ExchangeRateSeeder extends Seeder
|
||||
'rate' => $rate
|
||||
]);
|
||||
}
|
||||
|
||||
private function getCurrency(string $code): null|TransactionCurrency
|
||||
{
|
||||
return TransactionCurrency::whereNull('deleted_at')->where('code', $code)->first();
|
||||
}
|
||||
|
||||
private function hasRate(User $user, TransactionCurrency $from, TransactionCurrency $to, string $date): bool
|
||||
{
|
||||
return $user->currencyExchangeRates()->where('from_currency_id', $from->id)->where('to_currency_id', $to->id)->where('date', $date)->count() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user