mirror of
				https://github.com/firefly-iii/firefly-iii.git
				synced 2025-11-03 20:55:05 +00:00 
			
		
		
		
	Skip creation using if statement.
This commit is contained in:
		@@ -33,7 +33,7 @@ use Illuminate\Console\Command;
 | 
			
		||||
class CorrectAccountBalance extends Command
 | 
			
		||||
{
 | 
			
		||||
    use ShowsFriendlyMessages;
 | 
			
		||||
    public const string CONFIG_NAME = '620_correct_balances';
 | 
			
		||||
    public const string CONFIG_NAME = '610_correct_balances';
 | 
			
		||||
    protected $description = 'Recalculate all account balance amounts';
 | 
			
		||||
 | 
			
		||||
    protected $signature   = 'firefly-iii:correct-account-balance {--F|force : Force the execution of this command.}';
 | 
			
		||||
 
 | 
			
		||||
@@ -49,10 +49,12 @@ class AccountTypeSeeder extends Seeder
 | 
			
		||||
            AccountType::LIABILITY_CREDIT,
 | 
			
		||||
        ];
 | 
			
		||||
        foreach ($types as $type) {
 | 
			
		||||
            try {
 | 
			
		||||
                AccountType::create(['type' => $type]);
 | 
			
		||||
            } catch (\PDOException $e) {
 | 
			
		||||
                // @ignoreException
 | 
			
		||||
            if(null === AccountType::where('type', $type)->first()) {
 | 
			
		||||
                try {
 | 
			
		||||
                    AccountType::create(['type' => $type]);
 | 
			
		||||
                } catch (\PDOException $e) {
 | 
			
		||||
                    // @ignoreException
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -44,11 +44,10 @@ class ConfigSeeder extends Seeder
 | 
			
		||||
                    'data' => 1,
 | 
			
		||||
                ]
 | 
			
		||||
            );
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if (null !== $entry) {
 | 
			
		||||
            $version     = (int)config('firefly.db_version');
 | 
			
		||||
            $entry->data = $version;
 | 
			
		||||
            $entry->save();
 | 
			
		||||
        }
 | 
			
		||||
        $version     = (int) config('firefly.db_version');
 | 
			
		||||
        $entry->data = $version;
 | 
			
		||||
        $entry->save();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -60,10 +60,12 @@ class LinkTypeSeeder extends Seeder
 | 
			
		||||
            ],
 | 
			
		||||
        ];
 | 
			
		||||
        foreach ($types as $type) {
 | 
			
		||||
            try {
 | 
			
		||||
                LinkType::create($type);
 | 
			
		||||
            } catch (\PDOException $e) {
 | 
			
		||||
                // @ignoreException
 | 
			
		||||
            if (null === LinkType::where('name', $type['name'])->first()) {
 | 
			
		||||
                try {
 | 
			
		||||
                    LinkType::create($type);
 | 
			
		||||
                } catch (\PDOException $e) {
 | 
			
		||||
                    // @ignoreException
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -46,11 +46,14 @@ class PermissionSeeder extends Seeder
 | 
			
		||||
            ],
 | 
			
		||||
        ];
 | 
			
		||||
        foreach ($roles as $role) {
 | 
			
		||||
            try {
 | 
			
		||||
                Role::create($role);
 | 
			
		||||
            } catch (\PDOException $e) {
 | 
			
		||||
                // @ignoreException
 | 
			
		||||
            if (null === Role::where('name', $role['name'])->first()) {
 | 
			
		||||
                try {
 | 
			
		||||
                    Role::create($role);
 | 
			
		||||
                } catch (\PDOException $e) {
 | 
			
		||||
                    // @ignoreException
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -71,10 +71,12 @@ class TransactionCurrencySeeder extends Seeder
 | 
			
		||||
        $currencies[] = ['code' => 'HRK', 'name' => 'Croatian kuna', 'symbol' => 'kn', 'decimal_places' => 2];
 | 
			
		||||
 | 
			
		||||
        foreach ($currencies as $currency) {
 | 
			
		||||
            try {
 | 
			
		||||
                TransactionCurrency::create($currency);
 | 
			
		||||
            } catch (\PDOException $e) {
 | 
			
		||||
                // @ignoreException
 | 
			
		||||
            if(null === TransactionCurrency::where('code', $currency['code'])->first()) {
 | 
			
		||||
                try {
 | 
			
		||||
                    TransactionCurrency::create($currency);
 | 
			
		||||
                } catch (\PDOException $e) {
 | 
			
		||||
                    // @ignoreException
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -44,10 +44,12 @@ class TransactionTypeSeeder extends Seeder
 | 
			
		||||
        ];
 | 
			
		||||
 | 
			
		||||
        foreach ($types as $type) {
 | 
			
		||||
            try {
 | 
			
		||||
                TransactionType::create(['type' => $type]);
 | 
			
		||||
            } catch (\PDOException $e) {
 | 
			
		||||
                // @ignoreException
 | 
			
		||||
            if(null === TransactionType::where('type', $type)->first()) {
 | 
			
		||||
                try {
 | 
			
		||||
                    TransactionType::create(['type' => $type]);
 | 
			
		||||
                } catch (\PDOException $e) {
 | 
			
		||||
                    // @ignoreException
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -45,10 +45,12 @@ class UserRoleSeeder extends Seeder
 | 
			
		||||
 | 
			
		||||
        /** @var string $role */
 | 
			
		||||
        foreach ($roles as $role) {
 | 
			
		||||
            try {
 | 
			
		||||
                UserRole::create(['title' => $role]);
 | 
			
		||||
            } catch (\PDOException $e) {
 | 
			
		||||
                // @ignoreException
 | 
			
		||||
            if(null === UserRole::where('title', $role)->first()) {
 | 
			
		||||
                try {
 | 
			
		||||
                    UserRole::create(['title' => $role]);
 | 
			
		||||
                } catch (\PDOException $e) {
 | 
			
		||||
                    // @ignoreException
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user