move migration

This commit is contained in:
Yuri Kuznetsov
2024-04-23 17:09:26 +03:00
parent 665dd2f242
commit 15b4ce9657
2 changed files with 58 additions and 14 deletions
@@ -33,11 +33,8 @@ use Espo\Core\Upgrades\Migration\Script;
use Espo\Core\InjectableFactory;
use Espo\Core\Utils\Config;
use Espo\Core\Utils\Metadata;
use Espo\Entities\Role;
use Espo\Entities\Template;
use Espo\ORM\EntityManager;
use Espo\ORM\Query\Part\Expression;
use Espo\ORM\Query\UpdateBuilder;
use Espo\Tools\Pdf\Template as PdfTemplate;
class AfterUpgrade implements Script
@@ -64,7 +61,6 @@ class AfterUpgrade implements Script
$this->updateTemplates($em, $config);
$this->updateTargetList($this->metadata);
$this->updateRoles();
}
private function updateTemplates(EntityManager $entityManager, Config $config): void
@@ -126,14 +122,4 @@ class AfterUpgrade implements Script
$metadata->save();
}
private function updateRoles(): void
{
$query = UpdateBuilder::create()
->in(Role::ENTITY_TYPE)
->set(['mentionPermission' => Expression::column('assignmentPermission')])
->build();
$this->entityManager->getQueryExecutor()->execute($query);
}
}
@@ -0,0 +1,58 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2024 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
* Website: https://www.espocrm.com
*
* 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.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* 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/>.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
namespace Espo\Core\Upgrades\Migrations\V8_3;
use Espo\Core\Upgrades\Migration\Script;
use Espo\Entities\Role;
use Espo\ORM\EntityManager;
use Espo\ORM\Query\Part\Expression;
use Espo\ORM\Query\UpdateBuilder;
class AfterUpgrade implements Script
{
public function __construct(
private EntityManager $entityManager,
) {}
public function run(): void
{
$this->updateRoles();
}
private function updateRoles(): void
{
$query = UpdateBuilder::create()
->in(Role::ENTITY_TYPE)
->set(['mentionPermission' => Expression::column('assignmentPermission')])
->build();
$this->entityManager->getQueryExecutor()->execute($query);
}
}