mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Some code cleanup and a new migration.
This commit is contained in:
@@ -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']);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
@@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class CreateUsersTable.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class CreateUsersTable extends Migration
|
||||
|
@@ -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')) {
|
||||
|
@@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesFor3101.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesFor3101 extends Migration
|
||||
|
@@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class FixNullables.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class FixNullables extends Migration
|
||||
|
@@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ExpandTransactionsTable.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ExpandTransactionsTable extends Migration
|
||||
|
@@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV410.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV410 extends Migration
|
||||
|
@@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV420.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV420 extends Migration
|
||||
|
@@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV430.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV430 extends Migration
|
||||
|
@@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV431.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV431 extends Migration
|
||||
|
@@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV440.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV440 extends Migration
|
||||
|
@@ -25,6 +25,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV450.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV450 extends Migration
|
||||
|
@@ -26,6 +26,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class ChangesForV470.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV470 extends Migration
|
||||
|
@@ -26,6 +26,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class ChangesForV470a.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV470a extends Migration
|
||||
|
@@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class CreateOauthAuthCodesTable.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class CreateOauthAuthCodesTable extends Migration
|
||||
|
@@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class CreateOauthAccessTokensTable.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class CreateOauthAccessTokensTable extends Migration
|
||||
|
@@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class CreateOauthRefreshTokensTable.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class CreateOauthRefreshTokensTable extends Migration
|
||||
|
@@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class CreateOauthClientsTable.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class CreateOauthClientsTable extends Migration
|
||||
|
@@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class CreateOauthPersonalAccessClientsTable.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class CreateOauthPersonalAccessClientsTable extends Migration
|
||||
|
@@ -27,6 +27,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV472.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV472 extends Migration
|
||||
|
@@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class ChangesForV473.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV473 extends Migration
|
||||
|
@@ -27,6 +27,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV474.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV474 extends Migration
|
||||
|
@@ -27,6 +27,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV475.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV475 extends Migration
|
||||
|
@@ -27,6 +27,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV477.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV477 extends Migration
|
||||
|
@@ -27,6 +27,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV479.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV479 extends Migration
|
||||
|
@@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class ChangesForV4710
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV4710 extends Migration
|
||||
|
@@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class ChangesForV4711
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV4711 extends Migration
|
||||
|
@@ -27,6 +27,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class ChangesForV4712.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV4712 extends Migration
|
||||
|
@@ -27,6 +27,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class FixLdapConfiguration.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class FixLdapConfiguration extends Migration
|
||||
|
@@ -26,6 +26,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV480.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV480 extends Migration
|
||||
|
@@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class MakeLocationsTable.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class MakeLocationsTable extends Migration
|
||||
|
@@ -28,6 +28,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV520.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV520 extends Migration
|
||||
|
@@ -27,6 +27,7 @@ use Illuminate\Database\Schema\Blueprint;
|
||||
|
||||
/**
|
||||
* Class ChangesForV530
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV530 extends Migration
|
||||
|
@@ -28,6 +28,7 @@ use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class ChangesForV530a
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
class ChangesForV530a extends Migration
|
||||
|
@@ -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();
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
44
database/migrations/2021_03_12_061213_changes_for_v550b2.php
Normal file
44
database/migrations/2021_03_12_061213_changes_for_v550b2.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Class ChangesForV550b2
|
||||
*/
|
||||
class ChangesForV550b2 extends Migration
|
||||
{
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table(
|
||||
'recurrences_transactions', function (Blueprint $table) {
|
||||
|
||||
$table->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');
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user