2019-03-23 08:10:59 +01:00
|
|
|
<?php
|
2024-11-25 04:18:55 +01:00
|
|
|
|
2019-03-23 08:10:59 +01:00
|
|
|
/**
|
|
|
|
|
* CorrectDatabase.php
|
2020-01-23 20:35:02 +01:00
|
|
|
* Copyright (c) 2020 james@firefly-iii.org
|
2019-03-23 08:10:59 +01:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2019-03-23 08:10:59 +01:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
2019-03-23 08:10:59 +01:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2019-03-23 08:10:59 +01:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-10-02 06:37:26 +02:00
|
|
|
* GNU Affero General Public License for more details.
|
2019-03-23 08:10:59 +01:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2019-03-23 08:10:59 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
|
|
namespace FireflyIII\Console\Commands\Correction;
|
|
|
|
|
|
2023-06-20 07:16:56 +02:00
|
|
|
use FireflyIII\Console\Commands\ShowsFriendlyMessages;
|
2019-03-23 08:10:59 +01:00
|
|
|
use Illuminate\Console\Command;
|
2025-05-24 17:19:18 +02:00
|
|
|
use Illuminate\Support\Facades\Schema;
|
2019-03-23 08:10:59 +01:00
|
|
|
|
2024-12-27 06:56:08 +01:00
|
|
|
class CorrectsDatabase extends Command
|
2019-03-23 08:10:59 +01:00
|
|
|
{
|
2023-06-20 07:16:56 +02:00
|
|
|
use ShowsFriendlyMessages;
|
|
|
|
|
|
2024-12-27 06:48:58 +01:00
|
|
|
protected $description = 'Will validate and correct the integrity of your database, if necessary.';
|
2023-06-02 07:36:17 +02:00
|
|
|
protected $signature = 'firefly-iii:correct-database';
|
2019-03-23 08:10:59 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Execute the console command.
|
|
|
|
|
*/
|
|
|
|
|
public function handle(): int
|
|
|
|
|
{
|
|
|
|
|
// if table does not exist, return false
|
2025-05-24 17:19:18 +02:00
|
|
|
if (!Schema::hasTable('users')) {
|
2023-06-20 07:16:56 +02:00
|
|
|
$this->friendlyError('No "users"-table, will not continue.');
|
2023-05-29 13:56:55 +02:00
|
|
|
|
2019-03-23 08:10:59 +01:00
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
$commands = [
|
2024-12-27 07:24:47 +01:00
|
|
|
'correction:restore-oauth-keys',
|
|
|
|
|
'correction:timezones',
|
|
|
|
|
'correction:create-group-memberships',
|
|
|
|
|
'correction:group-information',
|
|
|
|
|
'correction:piggy-banks',
|
|
|
|
|
'correction:link-types',
|
|
|
|
|
'correction:access-tokens',
|
|
|
|
|
'correction:bills',
|
|
|
|
|
'correction:amounts',
|
|
|
|
|
'correction:currencies',
|
|
|
|
|
'correction:transfer-budgets',
|
|
|
|
|
'correction:uneven-amounts',
|
|
|
|
|
'correction:zero-amounts',
|
|
|
|
|
'correction:orphaned-transactions',
|
|
|
|
|
'correction:empty-journals',
|
|
|
|
|
'correction:empty-groups',
|
|
|
|
|
'correction:account-types',
|
|
|
|
|
'correction:ibans',
|
|
|
|
|
'correction:account-order',
|
|
|
|
|
'correction:meta-fields',
|
2024-12-27 07:29:17 +01:00
|
|
|
'correction:opening-balance-currencies',
|
|
|
|
|
'correction:long-descriptions',
|
|
|
|
|
'correction:recurring-transactions',
|
|
|
|
|
'correction:frontpage-accounts',
|
|
|
|
|
'correction:group-accounts',
|
|
|
|
|
'correction:recalculates-liabilities',
|
|
|
|
|
'correction:preferences',
|
2024-12-27 07:24:47 +01:00
|
|
|
// 'correction:transaction-types', // resource heavy, disabled.
|
2025-09-16 20:44:54 +02:00
|
|
|
'correction:recalculate-pc-amounts',
|
|
|
|
|
'correction:remove-links-to-deleted-objects',
|
2024-12-27 07:24:47 +01:00
|
|
|
'firefly-iii:report-integrity',
|
2019-03-23 08:10:59 +01:00
|
|
|
];
|
|
|
|
|
foreach ($commands as $command) {
|
2023-06-20 07:16:56 +02:00
|
|
|
$this->friendlyLine(sprintf('Now executing command "%s"', $command));
|
2023-04-16 07:33:12 +02:00
|
|
|
$this->call($command);
|
2019-03-23 08:10:59 +01:00
|
|
|
}
|
2020-03-21 15:43:41 +01:00
|
|
|
|
2019-03-23 08:10:59 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
2019-08-17 12:09:03 +02:00
|
|
|
}
|