mirror of
https://github.com/SuiteCRM/SuiteCRM-Core.git
synced 2025-08-29 01:10:42 +08:00
Add Migration to check for log dir
This commit is contained in:
parent
734dc100d9
commit
0fe9beb39a
1 changed files with 51 additions and 0 deletions
51
core/backend/Migrations/Version20250127092820.php
Normal file
51
core/backend/Migrations/Version20250127092820.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Migrations;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20250127092820 extends BaseMigration implements ContainerAwareInterface
|
||||
{
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Update Log Dir in config.php';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
|
||||
$systemConfigsHandler = $this->container->get('app.system-configs');
|
||||
$systemConfigs = $systemConfigsHandler?->getConfigs();
|
||||
|
||||
if ($systemConfigs['log_dir'] === '../../logs/legacy') {
|
||||
$this->log('Log Dir already up to date');
|
||||
return;
|
||||
}
|
||||
|
||||
$logPaths = [
|
||||
'.',
|
||||
'',
|
||||
'./'
|
||||
];
|
||||
|
||||
if (in_array($systemConfigs['log_dir'], $logPaths, true)) {
|
||||
$systemConfigs['log_dir'] = '../../logs/legacy';
|
||||
$systemConfigsHandler?->updateSystemConfig($systemConfigs);
|
||||
$this->log('Updated Log Dir in config.php');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->log('Log Dir already Updated');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue