From 97561ab9c99389786bfdc5f6d75081045f73563b Mon Sep 17 00:00:00 2001 From: James Cole Date: Fri, 12 Mar 2021 06:17:50 +0100 Subject: [PATCH] Some code cleanup and a new migration. --- ...016_06_16_000000_create_support_tables.php | 85 ++++++------- .../2016_06_16_000001_create_users_table.php | 1 + .../2016_06_16_000002_create_main_tables.php | 77 ++++++------ .../2016_08_25_091522_changes_for_3101.php | 1 + .../2016_09_12_121359_fix_nullables.php | 1 + ...10_09_150037_expand_transactions_table.php | 1 + .../2016_10_22_075804_changes_for_v410.php | 1 + .../2016_11_24_210552_changes_for_v420.php | 1 + .../2016_12_22_150431_changes_for_v430.php | 1 + .../2016_12_28_203205_changes_for_v431.php | 1 + .../2017_04_13_163623_changes_for_v440.php | 1 + .../2017_06_02_105232_changes_for_v450.php | 1 + .../2017_08_20_062014_changes_for_v470.php | 1 + .../2017_11_04_170844_changes_for_v470a.php | 1 + ...1_000001_create_oauth_auth_codes_table.php | 15 +-- ...00002_create_oauth_access_tokens_table.php | 19 +-- ...0003_create_oauth_refresh_tokens_table.php | 11 +- ...1_01_000004_create_oauth_clients_table.php | 21 ++-- ...te_oauth_personal_access_clients_table.php | 9 +- .../2018_03_19_141348_changes_for_v472.php | 1 + .../2018_04_07_210913_changes_for_v473.php | 1 + .../2018_04_29_174524_changes_for_v474.php | 1 + .../2018_06_08_200526_changes_for_v475.php | 119 +++++++++--------- .../2018_09_05_195147_changes_for_v477.php | 11 +- .../2018_11_06_172532_changes_for_v479.php | 5 +- .../2019_01_28_193833_changes_for_v4710.php | 15 +-- .../2019_02_05_055516_changes_for_v4711.php | 9 +- .../2019_02_11_170529_changes_for_v4712.php | 5 +- ...19_03_11_223700_fix_ldap_configuration.php | 9 +- .../2019_03_22_183214_changes_for_v480.php | 17 +-- ...2019_12_28_191351_make_locations_table.php | 19 +-- .../2020_03_13_201950_changes_for_v520.php | 1 + .../2020_06_07_063612_changes_for_v530.php | 1 + .../2020_06_30_202620_changes_for_v530a.php | 1 + .../2020_07_24_162820_changes_for_v540.php | 7 +- .../2021_03_12_061213_changes_for_v550b2.php | 44 +++++++ 36 files changed, 298 insertions(+), 217 deletions(-) create mode 100644 database/migrations/2021_03_12_061213_changes_for_v550b2.php diff --git a/database/migrations/2016_06_16_000000_create_support_tables.php b/database/migrations/2016_06_16_000000_create_support_tables.php index 077eddc433..4d158e268f 100644 --- a/database/migrations/2016_06_16_000000_create_support_tables.php +++ b/database/migrations/2016_06_16_000000_create_support_tables.php @@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class CreateSupportTables. + * * @codeCoverageIgnore */ class CreateSupportTables extends Migration @@ -82,23 +83,6 @@ class CreateSupportTables extends Migration } } - private function createConfigurationTable(): void - { - if (!Schema::hasTable('configuration')) { - Schema::create( - 'configuration', - static function (Blueprint $table) { - $table->increments('id'); - $table->timestamps(); - $table->softDeletes(); - $table->string('name', 50); - $table->text('data'); - $table->unique(['name']); - } - ); - } - } - private function createCurrencyTable(): void { if (!Schema::hasTable('transaction_currencies')) { @@ -119,6 +103,24 @@ class CreateSupportTables extends Migration } } + private function createTransactionTypeTable(): void + { + if (!Schema::hasTable('transaction_types')) { + Schema::create( + 'transaction_types', + static function (Blueprint $table) { + $table->increments('id'); + $table->timestamps(); + $table->softDeletes(); + $table->string('type', 50); + + // type must be unique. + $table->unique(['type']); + } + ); + } + } + private function createJobsTable(): void { if (!Schema::hasTable('jobs')) { @@ -155,24 +157,6 @@ class CreateSupportTables extends Migration } } - private function createPermissionRoleTable(): void - { - if (!Schema::hasTable('permission_role')) { - Schema::create( - 'permission_role', - static function (Blueprint $table) { - $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']); - } - ); - } - } - private function createPermissionsTable(): void { if (!Schema::hasTable('permissions')) { @@ -205,6 +189,24 @@ class CreateSupportTables extends Migration } } + private function createPermissionRoleTable(): void + { + if (!Schema::hasTable('permission_role')) { + Schema::create( + 'permission_role', + static function (Blueprint $table) { + $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']); + } + ); + } + } + private function createSessionsTable(): void { if (!Schema::hasTable('sessions')) { @@ -222,19 +224,18 @@ class CreateSupportTables extends Migration } } - private function createTransactionTypeTable(): void + private function createConfigurationTable(): void { - if (!Schema::hasTable('transaction_types')) { + if (!Schema::hasTable('configuration')) { Schema::create( - 'transaction_types', + 'configuration', static function (Blueprint $table) { $table->increments('id'); $table->timestamps(); $table->softDeletes(); - $table->string('type', 50); - - // type must be unique. - $table->unique(['type']); + $table->string('name', 50); + $table->text('data'); + $table->unique(['name']); } ); } diff --git a/database/migrations/2016_06_16_000001_create_users_table.php b/database/migrations/2016_06_16_000001_create_users_table.php index 412593602d..51202b645f 100644 --- a/database/migrations/2016_06_16_000001_create_users_table.php +++ b/database/migrations/2016_06_16_000001_create_users_table.php @@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class CreateUsersTable. + * * @codeCoverageIgnore */ class CreateUsersTable extends Migration diff --git a/database/migrations/2016_06_16_000002_create_main_tables.php b/database/migrations/2016_06_16_000002_create_main_tables.php index f0ab7205b9..9fb67c46ac 100644 --- a/database/migrations/2016_06_16_000002_create_main_tables.php +++ b/database/migrations/2016_06_16_000002_create_main_tables.php @@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class CreateMainTables. + * * @codeCoverageIgnore */ class CreateMainTables extends Migration @@ -122,6 +123,44 @@ class CreateMainTables extends Migration } } + private function createPiggyBanksTable(): void + { + if (!Schema::hasTable('piggy_banks')) { + Schema::create( + 'piggy_banks', + static function (Blueprint $table) { + $table->increments('id'); + $table->timestamps(); + $table->softDeletes(); + $table->integer('account_id', false, true); + $table->string('name', 1024); + $table->decimal('targetamount', 22, 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'); + } + ); + } + + if (!Schema::hasTable('piggy_bank_repetitions')) { + Schema::create( + 'piggy_bank_repetitions', + static function (Blueprint $table) { + $table->increments('id'); + $table->timestamps(); + $table->integer('piggy_bank_id', false, true); + $table->date('startdate')->nullable(); + $table->date('targetdate')->nullable(); + $table->decimal('currentamount', 22, 12); + $table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade'); + } + ); + } + } + private function createAttachmentsTable(): void { if (!Schema::hasTable('attachments')) { @@ -283,44 +322,6 @@ class CreateMainTables extends Migration } } - private function createPiggyBanksTable(): void - { - if (!Schema::hasTable('piggy_banks')) { - Schema::create( - 'piggy_banks', - static function (Blueprint $table) { - $table->increments('id'); - $table->timestamps(); - $table->softDeletes(); - $table->integer('account_id', false, true); - $table->string('name', 1024); - $table->decimal('targetamount', 22, 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'); - } - ); - } - - if (!Schema::hasTable('piggy_bank_repetitions')) { - Schema::create( - 'piggy_bank_repetitions', - static function (Blueprint $table) { - $table->increments('id'); - $table->timestamps(); - $table->integer('piggy_bank_id', false, true); - $table->date('startdate')->nullable(); - $table->date('targetdate')->nullable(); - $table->decimal('currentamount', 22, 12); - $table->foreign('piggy_bank_id')->references('id')->on('piggy_banks')->onDelete('cascade'); - } - ); - } - } - private function createPreferencesTable(): void { if (!Schema::hasTable('preferences')) { diff --git a/database/migrations/2016_08_25_091522_changes_for_3101.php b/database/migrations/2016_08_25_091522_changes_for_3101.php index 2314ef38c4..237821a2c4 100644 --- a/database/migrations/2016_08_25_091522_changes_for_3101.php +++ b/database/migrations/2016_08_25_091522_changes_for_3101.php @@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ChangesFor3101. + * * @codeCoverageIgnore */ class ChangesFor3101 extends Migration diff --git a/database/migrations/2016_09_12_121359_fix_nullables.php b/database/migrations/2016_09_12_121359_fix_nullables.php index 05cd49e550..34c857cddb 100644 --- a/database/migrations/2016_09_12_121359_fix_nullables.php +++ b/database/migrations/2016_09_12_121359_fix_nullables.php @@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class FixNullables. + * * @codeCoverageIgnore */ class FixNullables extends Migration diff --git a/database/migrations/2016_10_09_150037_expand_transactions_table.php b/database/migrations/2016_10_09_150037_expand_transactions_table.php index 0d4274a947..162da9df5e 100644 --- a/database/migrations/2016_10_09_150037_expand_transactions_table.php +++ b/database/migrations/2016_10_09_150037_expand_transactions_table.php @@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ExpandTransactionsTable. + * * @codeCoverageIgnore */ class ExpandTransactionsTable extends Migration diff --git a/database/migrations/2016_10_22_075804_changes_for_v410.php b/database/migrations/2016_10_22_075804_changes_for_v410.php index 73ee4de023..5d53fc84e3 100644 --- a/database/migrations/2016_10_22_075804_changes_for_v410.php +++ b/database/migrations/2016_10_22_075804_changes_for_v410.php @@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ChangesForV410. + * * @codeCoverageIgnore */ class ChangesForV410 extends Migration diff --git a/database/migrations/2016_11_24_210552_changes_for_v420.php b/database/migrations/2016_11_24_210552_changes_for_v420.php index 1d80ba5742..3e52c1578b 100644 --- a/database/migrations/2016_11_24_210552_changes_for_v420.php +++ b/database/migrations/2016_11_24_210552_changes_for_v420.php @@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ChangesForV420. + * * @codeCoverageIgnore */ class ChangesForV420 extends Migration diff --git a/database/migrations/2016_12_22_150431_changes_for_v430.php b/database/migrations/2016_12_22_150431_changes_for_v430.php index 34c7995796..7466b224d7 100644 --- a/database/migrations/2016_12_22_150431_changes_for_v430.php +++ b/database/migrations/2016_12_22_150431_changes_for_v430.php @@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ChangesForV430. + * * @codeCoverageIgnore */ class ChangesForV430 extends Migration diff --git a/database/migrations/2016_12_28_203205_changes_for_v431.php b/database/migrations/2016_12_28_203205_changes_for_v431.php index f07d68c129..57eac036c3 100644 --- a/database/migrations/2016_12_28_203205_changes_for_v431.php +++ b/database/migrations/2016_12_28_203205_changes_for_v431.php @@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ChangesForV431. + * * @codeCoverageIgnore */ class ChangesForV431 extends Migration diff --git a/database/migrations/2017_04_13_163623_changes_for_v440.php b/database/migrations/2017_04_13_163623_changes_for_v440.php index 63b3818b70..772ab5b783 100644 --- a/database/migrations/2017_04_13_163623_changes_for_v440.php +++ b/database/migrations/2017_04_13_163623_changes_for_v440.php @@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ChangesForV440. + * * @codeCoverageIgnore */ class ChangesForV440 extends Migration diff --git a/database/migrations/2017_06_02_105232_changes_for_v450.php b/database/migrations/2017_06_02_105232_changes_for_v450.php index 5fb701d70c..351324af06 100644 --- a/database/migrations/2017_06_02_105232_changes_for_v450.php +++ b/database/migrations/2017_06_02_105232_changes_for_v450.php @@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ChangesForV450. + * * @codeCoverageIgnore */ class ChangesForV450 extends Migration diff --git a/database/migrations/2017_08_20_062014_changes_for_v470.php b/database/migrations/2017_08_20_062014_changes_for_v470.php index e6ca3225f5..0c2471d80c 100644 --- a/database/migrations/2017_08_20_062014_changes_for_v470.php +++ b/database/migrations/2017_08_20_062014_changes_for_v470.php @@ -26,6 +26,7 @@ use Illuminate\Support\Facades\Schema; /** * Class ChangesForV470. + * * @codeCoverageIgnore */ class ChangesForV470 extends Migration diff --git a/database/migrations/2017_11_04_170844_changes_for_v470a.php b/database/migrations/2017_11_04_170844_changes_for_v470a.php index 97ff6d47ec..94fab9c06d 100644 --- a/database/migrations/2017_11_04_170844_changes_for_v470a.php +++ b/database/migrations/2017_11_04_170844_changes_for_v470a.php @@ -26,6 +26,7 @@ use Illuminate\Support\Facades\Schema; /** * Class ChangesForV470a. + * * @codeCoverageIgnore */ class ChangesForV470a extends Migration diff --git a/database/migrations/2018_01_01_000001_create_oauth_auth_codes_table.php b/database/migrations/2018_01_01_000001_create_oauth_auth_codes_table.php index c742de5ac5..9936125826 100644 --- a/database/migrations/2018_01_01_000001_create_oauth_auth_codes_table.php +++ b/database/migrations/2018_01_01_000001_create_oauth_auth_codes_table.php @@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema; /** * Class CreateOauthAuthCodesTable. + * * @codeCoverageIgnore */ class CreateOauthAuthCodesTable extends Migration @@ -48,13 +49,13 @@ class CreateOauthAuthCodesTable extends Migration { Schema::create( 'oauth_auth_codes', static function (Blueprint $table) { - $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(); - } + $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(); + } ); } } diff --git a/database/migrations/2018_01_01_000002_create_oauth_access_tokens_table.php b/database/migrations/2018_01_01_000002_create_oauth_access_tokens_table.php index fa1dd8a426..a80077fde9 100644 --- a/database/migrations/2018_01_01_000002_create_oauth_access_tokens_table.php +++ b/database/migrations/2018_01_01_000002_create_oauth_access_tokens_table.php @@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema; /** * Class CreateOauthAccessTokensTable. + * * @codeCoverageIgnore */ class CreateOauthAccessTokensTable extends Migration @@ -48,15 +49,15 @@ class CreateOauthAccessTokensTable extends Migration { Schema::create( 'oauth_access_tokens', static function (Blueprint $table) { - $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(); - } + $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(); + } ); } } diff --git a/database/migrations/2018_01_01_000003_create_oauth_refresh_tokens_table.php b/database/migrations/2018_01_01_000003_create_oauth_refresh_tokens_table.php index 8be1de2134..945fcd37b2 100644 --- a/database/migrations/2018_01_01_000003_create_oauth_refresh_tokens_table.php +++ b/database/migrations/2018_01_01_000003_create_oauth_refresh_tokens_table.php @@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema; /** * Class CreateOauthRefreshTokensTable. + * * @codeCoverageIgnore */ class CreateOauthRefreshTokensTable extends Migration @@ -48,11 +49,11 @@ class CreateOauthRefreshTokensTable extends Migration { Schema::create( 'oauth_refresh_tokens', static function (Blueprint $table) { - $table->string('id', 100)->primary(); - $table->string('access_token_id', 100)->index(); - $table->boolean('revoked'); - $table->dateTime('expires_at')->nullable(); - } + $table->string('id', 100)->primary(); + $table->string('access_token_id', 100)->index(); + $table->boolean('revoked'); + $table->dateTime('expires_at')->nullable(); + } ); } } diff --git a/database/migrations/2018_01_01_000004_create_oauth_clients_table.php b/database/migrations/2018_01_01_000004_create_oauth_clients_table.php index ebac9eef8d..a98019c89b 100644 --- a/database/migrations/2018_01_01_000004_create_oauth_clients_table.php +++ b/database/migrations/2018_01_01_000004_create_oauth_clients_table.php @@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema; /** * Class CreateOauthClientsTable. + * * @codeCoverageIgnore */ class CreateOauthClientsTable extends Migration @@ -48,16 +49,16 @@ class CreateOauthClientsTable extends Migration { Schema::create( 'oauth_clients', static function (Blueprint $table) { - $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(); - } + $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(); + } ); } } diff --git a/database/migrations/2018_01_01_000005_create_oauth_personal_access_clients_table.php b/database/migrations/2018_01_01_000005_create_oauth_personal_access_clients_table.php index b8dce06bb1..95b52f4e1f 100644 --- a/database/migrations/2018_01_01_000005_create_oauth_personal_access_clients_table.php +++ b/database/migrations/2018_01_01_000005_create_oauth_personal_access_clients_table.php @@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema; /** * Class CreateOauthPersonalAccessClientsTable. + * * @codeCoverageIgnore */ class CreateOauthPersonalAccessClientsTable extends Migration @@ -48,10 +49,10 @@ class CreateOauthPersonalAccessClientsTable extends Migration { Schema::create( 'oauth_personal_access_clients', static function (Blueprint $table) { - $table->increments('id'); - $table->integer('client_id')->index(); - $table->timestamps(); - } + $table->increments('id'); + $table->integer('client_id')->index(); + $table->timestamps(); + } ); } } diff --git a/database/migrations/2018_03_19_141348_changes_for_v472.php b/database/migrations/2018_03_19_141348_changes_for_v472.php index 66a87c26d3..060d83cf4b 100644 --- a/database/migrations/2018_03_19_141348_changes_for_v472.php +++ b/database/migrations/2018_03_19_141348_changes_for_v472.php @@ -27,6 +27,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ChangesForV472. + * * @codeCoverageIgnore */ class ChangesForV472 extends Migration diff --git a/database/migrations/2018_04_07_210913_changes_for_v473.php b/database/migrations/2018_04_07_210913_changes_for_v473.php index 62aca6b071..d659877176 100644 --- a/database/migrations/2018_04_07_210913_changes_for_v473.php +++ b/database/migrations/2018_04_07_210913_changes_for_v473.php @@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema; /** * Class ChangesForV473. + * * @codeCoverageIgnore */ class ChangesForV473 extends Migration diff --git a/database/migrations/2018_04_29_174524_changes_for_v474.php b/database/migrations/2018_04_29_174524_changes_for_v474.php index 5d055ce2f5..b1e9088b78 100644 --- a/database/migrations/2018_04_29_174524_changes_for_v474.php +++ b/database/migrations/2018_04_29_174524_changes_for_v474.php @@ -27,6 +27,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ChangesForV474. + * * @codeCoverageIgnore */ class ChangesForV474 extends Migration diff --git a/database/migrations/2018_06_08_200526_changes_for_v475.php b/database/migrations/2018_06_08_200526_changes_for_v475.php index dce990d133..166d6dfbcf 100644 --- a/database/migrations/2018_06_08_200526_changes_for_v475.php +++ b/database/migrations/2018_06_08_200526_changes_for_v475.php @@ -27,6 +27,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ChangesForV475. + * * @codeCoverageIgnore */ class ChangesForV475 extends Migration @@ -56,92 +57,92 @@ class ChangesForV475 extends Migration { Schema::create( 'recurrences', static function (Blueprint $table) { - $table->increments('id'); - $table->timestamps(); - $table->softDeletes(); - $table->integer('user_id', false, true); - $table->integer('transaction_type_id', false, true); + $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'); + } ); Schema::create( 'recurrences_transactions', static function (Blueprint $table) { - $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->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', 22, 12); - $table->decimal('foreign_amount', 22, 12)->nullable(); - $table->string('description', 1024); + $table->decimal('amount', 22, 12); + $table->decimal('foreign_amount', 22, 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'); + } ); Schema::create( 'recurrences_repetitions', static function (Blueprint $table) { - $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->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'); + } ); Schema::create( 'recurrences_meta', static function (Blueprint $table) { - $table->increments('id'); - $table->timestamps(); - $table->softDeletes(); - $table->integer('recurrence_id', false, true); + $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'); + } ); Schema::create( 'rt_meta', static function (Blueprint $table) { - $table->increments('id'); - $table->timestamps(); - $table->softDeletes(); - $table->integer('rt_id', false, true); + $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'); + } ); } } diff --git a/database/migrations/2018_09_05_195147_changes_for_v477.php b/database/migrations/2018_09_05_195147_changes_for_v477.php index 5a49e474bd..d9f9678942 100644 --- a/database/migrations/2018_09_05_195147_changes_for_v477.php +++ b/database/migrations/2018_09_05_195147_changes_for_v477.php @@ -27,6 +27,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ChangesForV477. + * * @codeCoverageIgnore */ class ChangesForV477 extends Migration @@ -42,12 +43,12 @@ class ChangesForV477 extends Migration 'budget_limits', static function (Blueprint $table) { // cannot drop foreign keys in SQLite: - if ('sqlite' !== config('database.default')) { - $table->dropForeign('budget_limits_transaction_currency_id_foreign'); - } - - $table->dropColumn(['transaction_currency_id']); + if ('sqlite' !== config('database.default')) { + $table->dropForeign('budget_limits_transaction_currency_id_foreign'); } + + $table->dropColumn(['transaction_currency_id']); + } ); } diff --git a/database/migrations/2018_11_06_172532_changes_for_v479.php b/database/migrations/2018_11_06_172532_changes_for_v479.php index 90df8e2499..3001eea2d3 100644 --- a/database/migrations/2018_11_06_172532_changes_for_v479.php +++ b/database/migrations/2018_11_06_172532_changes_for_v479.php @@ -27,6 +27,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ChangesForV479. + * * @codeCoverageIgnore */ class ChangesForV479 extends Migration @@ -40,8 +41,8 @@ class ChangesForV479 extends Migration { Schema::table( 'transaction_currencies', static function (Blueprint $table) { - $table->dropColumn(['enabled']); - } + $table->dropColumn(['enabled']); + } ); } diff --git a/database/migrations/2019_01_28_193833_changes_for_v4710.php b/database/migrations/2019_01_28_193833_changes_for_v4710.php index c32624a974..dfda36398d 100644 --- a/database/migrations/2019_01_28_193833_changes_for_v4710.php +++ b/database/migrations/2019_01_28_193833_changes_for_v4710.php @@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema; /** * Class ChangesForV4710 + * * @codeCoverageIgnore */ class ChangesForV4710 extends Migration @@ -54,14 +55,14 @@ class ChangesForV4710 extends Migration if (!Schema::hasTable('transaction_groups')) { Schema::create( 'transaction_groups', static function (Blueprint $table) { - $table->increments('id'); - $table->timestamps(); - $table->softDeletes(); - $table->integer('user_id', false, true); - $table->string('title', 1024)->nullable(); + $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'); + } ); } diff --git a/database/migrations/2019_02_05_055516_changes_for_v4711.php b/database/migrations/2019_02_05_055516_changes_for_v4711.php index 9cfc3f200c..1829ede413 100644 --- a/database/migrations/2019_02_05_055516_changes_for_v4711.php +++ b/database/migrations/2019_02_05_055516_changes_for_v4711.php @@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema; /** * Class ChangesForV4711 + * * @codeCoverageIgnore */ class ChangesForV4711 extends Migration @@ -60,14 +61,14 @@ class ChangesForV4711 extends Migration */ Schema::table( 'transaction_journals', static function (Blueprint $table) { - $table->dateTime('date')->change(); - } + $table->dateTime('date')->change(); + } ); Schema::table( 'preferences', static function (Blueprint $table) { - $table->text('data')->nullable()->change(); - } + $table->text('data')->nullable()->change(); + } ); } } diff --git a/database/migrations/2019_02_11_170529_changes_for_v4712.php b/database/migrations/2019_02_11_170529_changes_for_v4712.php index 24af68eb6f..8d235a6b4e 100644 --- a/database/migrations/2019_02_11_170529_changes_for_v4712.php +++ b/database/migrations/2019_02_11_170529_changes_for_v4712.php @@ -27,6 +27,7 @@ use Illuminate\Support\Facades\Schema; /** * Class ChangesForV4712. + * * @codeCoverageIgnore */ class ChangesForV4712 extends Migration @@ -59,8 +60,8 @@ class ChangesForV4712 extends Migration */ Schema::table( 'transaction_journals', static function (Blueprint $table) { - $table->dateTime('date')->change(); - } + $table->dateTime('date')->change(); + } ); } } diff --git a/database/migrations/2019_03_11_223700_fix_ldap_configuration.php b/database/migrations/2019_03_11_223700_fix_ldap_configuration.php index 4c3aa712a2..9f16faaa27 100644 --- a/database/migrations/2019_03_11_223700_fix_ldap_configuration.php +++ b/database/migrations/2019_03_11_223700_fix_ldap_configuration.php @@ -27,6 +27,7 @@ use Illuminate\Support\Facades\Schema; /** * Class FixLdapConfiguration. + * * @codeCoverageIgnore */ class FixLdapConfiguration extends Migration @@ -40,8 +41,8 @@ class FixLdapConfiguration extends Migration { Schema::table( 'users', static function (Blueprint $table) { - $table->dropColumn(['objectguid']); - } + $table->dropColumn(['objectguid']); + } ); } @@ -59,8 +60,8 @@ class FixLdapConfiguration extends Migration */ Schema::table( 'users', static function (Blueprint $table) { - $table->uuid('objectguid')->nullable()->after('id'); - } + $table->uuid('objectguid')->nullable()->after('id'); + } ); } } diff --git a/database/migrations/2019_03_22_183214_changes_for_v480.php b/database/migrations/2019_03_22_183214_changes_for_v480.php index 71f0b98752..d68a2fbffe 100644 --- a/database/migrations/2019_03_22_183214_changes_for_v480.php +++ b/database/migrations/2019_03_22_183214_changes_for_v480.php @@ -26,6 +26,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ChangesForV480. + * * @codeCoverageIgnore */ class ChangesForV480 extends Migration @@ -50,14 +51,14 @@ class ChangesForV480 extends Migration ); Schema::table( 'rule_groups', static function (Blueprint $table) { - $table->dropColumn('stop_processing'); - } + $table->dropColumn('stop_processing'); + } ); Schema::table( 'users', static function (Blueprint $table) { - $table->dropColumn('mfa_secret'); - } + $table->dropColumn('mfa_secret'); + } ); } @@ -84,13 +85,13 @@ class ChangesForV480 extends Migration ); Schema::table( 'rule_groups', static function (Blueprint $table) { - $table->boolean('stop_processing')->default(false); - } + $table->boolean('stop_processing')->default(false); + } ); Schema::table( 'users', static function (Blueprint $table) { - $table->string('mfa_secret', 50)->nullable(); - } + $table->string('mfa_secret', 50)->nullable(); + } ); } } diff --git a/database/migrations/2019_12_28_191351_make_locations_table.php b/database/migrations/2019_12_28_191351_make_locations_table.php index 30eefa6864..0f92217535 100644 --- a/database/migrations/2019_12_28_191351_make_locations_table.php +++ b/database/migrations/2019_12_28_191351_make_locations_table.php @@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema; /** * Class MakeLocationsTable. + * * @codeCoverageIgnore */ class MakeLocationsTable extends Migration @@ -51,17 +52,17 @@ class MakeLocationsTable extends Migration { Schema::create( 'locations', static function (Blueprint $table) { - $table->bigIncrements('id'); - $table->timestamps(); - $table->softDeletes(); + $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', 24, 12)->nullable(); - $table->decimal('longitude', 24, 12)->nullable(); - $table->smallInteger('zoom_level', false, true)->nullable(); - } + $table->decimal('latitude', 24, 12)->nullable(); + $table->decimal('longitude', 24, 12)->nullable(); + $table->smallInteger('zoom_level', false, true)->nullable(); + } ); } } diff --git a/database/migrations/2020_03_13_201950_changes_for_v520.php b/database/migrations/2020_03_13_201950_changes_for_v520.php index 7cfc93eeb2..72339f579b 100644 --- a/database/migrations/2020_03_13_201950_changes_for_v520.php +++ b/database/migrations/2020_03_13_201950_changes_for_v520.php @@ -28,6 +28,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ChangesForV520. + * * @codeCoverageIgnore */ class ChangesForV520 extends Migration diff --git a/database/migrations/2020_06_07_063612_changes_for_v530.php b/database/migrations/2020_06_07_063612_changes_for_v530.php index afc64f15c0..9e20abed8b 100644 --- a/database/migrations/2020_06_07_063612_changes_for_v530.php +++ b/database/migrations/2020_06_07_063612_changes_for_v530.php @@ -27,6 +27,7 @@ use Illuminate\Database\Schema\Blueprint; /** * Class ChangesForV530 + * * @codeCoverageIgnore */ class ChangesForV530 extends Migration diff --git a/database/migrations/2020_06_30_202620_changes_for_v530a.php b/database/migrations/2020_06_30_202620_changes_for_v530a.php index c5f85a156d..b5412de5d4 100644 --- a/database/migrations/2020_06_30_202620_changes_for_v530a.php +++ b/database/migrations/2020_06_30_202620_changes_for_v530a.php @@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema; /** * Class ChangesForV530a + * * @codeCoverageIgnore */ class ChangesForV530a extends Migration diff --git a/database/migrations/2020_07_24_162820_changes_for_v540.php b/database/migrations/2020_07_24_162820_changes_for_v540.php index bad51fd403..990ea11eac 100644 --- a/database/migrations/2020_07_24_162820_changes_for_v540.php +++ b/database/migrations/2020_07_24_162820_changes_for_v540.php @@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema; /** * Class ChangesForV540 + * * @codeCoverageIgnore */ class ChangesForV540 extends Migration @@ -85,8 +86,10 @@ class ChangesForV540 extends Migration // make column nullable: - Schema::table('oauth_clients', function (Blueprint $table) { + Schema::table( + 'oauth_clients', function (Blueprint $table) { $table->string('secret', 100)->nullable()->change(); - }); + } + ); } } diff --git a/database/migrations/2021_03_12_061213_changes_for_v550b2.php b/database/migrations/2021_03_12_061213_changes_for_v550b2.php new file mode 100644 index 0000000000..707b29ebf9 --- /dev/null +++ b/database/migrations/2021_03_12_061213_changes_for_v550b2.php @@ -0,0 +1,44 @@ +dropForeign('type_foreign'); + $table->dropColumn('transaction_type_id'); + + } + ); + } + + /** + * Run the migrations. + * + * @return void + */ + public function up(): void + { + // expand recurrence transaction table + Schema::table( + 'recurrences_transactions', function (Blueprint $table) { + $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'); + } + ); + } +}