diff --git a/upgrades/7.6/data.json b/upgrades/8.0.1-8.0.2/data.json similarity index 100% rename from upgrades/7.6/data.json rename to upgrades/8.0.1-8.0.2/data.json diff --git a/upgrades/8.0.1-8.0.2/scripts/AfterUpgrade.php b/upgrades/8.0.1-8.0.2/scripts/AfterUpgrade.php new file mode 100644 index 0000000000..f266fc5cd9 --- /dev/null +++ b/upgrades/8.0.1-8.0.2/scripts/AfterUpgrade.php @@ -0,0 +1,119 @@ +updateRoles( + $container->getByClass(EntityManager::class) + ); + + $this->updateMetadata( + $container->getByClass(Metadata::class) + ); + } + + private function updateRoles(EntityManager $entityManager): void + { + $query = UpdateBuilder::create() + ->in(Role::ENTITY_TYPE) + ->set(['messagePermission' => Expression::column('assignmentPermission')]) + ->build(); + + $entityManager->getQueryExecutor()->execute($query); + } + + private function updateMetadata(Metadata $metadata): void + { + $defs = $metadata->get(['scopes']); + + foreach ($defs as $entityType => $item) { + $isCustom = $item['isCustom'] ?? false; + $type = $item['type'] ?? false; + + if (!$isCustom) { + continue; + } + + if ($type === Event::TEMPLATE_TYPE) { + $metadata->set('entityDefs', $entityType, [ + 'fields' => [ + 'dateEnd' => [ + 'suppressValidationList' => ['required'], + ], + ] + ]); + + $metadata->save(); + + continue; + } + + if ( + !in_array($type, [ + BasePlus::TEMPLATE_TYPE, + Base::TEMPLATE_TYPE, + Company::TEMPLATE_TYPE, + Person::TEMPLATE_TYPE + ]) + ) { + continue; + } + + $recordDefs = $metadata->getCustom('recordDefs', $entityType) ?? (object) []; + $scopes = $metadata->getCustom('scopes', $entityType) ?? (object) []; + + $recordDefs->duplicateWhereBuilderClassName = "Espo\\Classes\\DuplicateWhereBuilders\\General"; + + if (!isset($scopes->duplicateCheckFieldList)) { + $scopes->duplicateCheckFieldList = []; + + if ($type === Company::TEMPLATE_TYPE || $type === Person::TEMPLATE_TYPE) { + $scopes->duplicateCheckFieldList = ['name', 'emailAddress']; + } + } + + $metadata->saveCustom('recordDefs', $entityType, $recordDefs); + $metadata->saveCustom('scopes', $entityType, $scopes); + } + } +} diff --git a/upgrades/8.0/data.json b/upgrades/8.0/data.json new file mode 100644 index 0000000000..60ec91eb56 --- /dev/null +++ b/upgrades/8.0/data.json @@ -0,0 +1,10 @@ +{ + "manifest": { + "delete": [ + "client/lib/original/espo.js", + "client/lib/espo.min.js", + "client/lib/espo.min.js.map", + "client/cfg/pre-load.json" + ] + } +} diff --git a/upgrades/7.6/scripts/AfterUpgrade.php b/upgrades/8.0/scripts/AfterUpgrade.php similarity index 100% rename from upgrades/7.6/scripts/AfterUpgrade.php rename to upgrades/8.0/scripts/AfterUpgrade.php diff --git a/upgrades/7.6/scripts/BeforeUpgrade.php b/upgrades/8.0/scripts/BeforeUpgrade.php similarity index 100% rename from upgrades/7.6/scripts/BeforeUpgrade.php rename to upgrades/8.0/scripts/BeforeUpgrade.php